Java JFrame Size lockInMinSize(final JFrame frame)

Here you can find the source of lockInMinSize(final JFrame frame)

Description

lock In Min Size

License

Open Source License

Declaration

public static void lockInMinSize(final JFrame frame) 

Method Source Code

//package com.java2s;
// GNU General Public License:                                                //

import java.awt.event.ComponentEvent;
import javax.swing.*;

public class Main {
    public static void lockInMinSize(final JFrame frame) {
        //Ensures user cannot resize frame to be smaller than frame is right now.
        final int origX = frame.getSize().width;
        final int origY = frame.getSize().height;
        //frame.setSize(new Dimension(origX, origY));
        frame.addComponentListener(new java.awt.event.ComponentAdapter() {
            @Override//ww w. j  a  v  a2  s. co  m
            public void componentResized(ComponentEvent event) {
                frame.setSize(Math.max(frame.getWidth(), origX), Math.max(frame.getHeight(), origY));
                frame.repaint();
            }
        });
    }
}

Related

  1. getFrameSize(Component c)
  2. getFrameSize(Component c)
  3. getFrameSize(Component c)
  4. isNormalSizeMode(JFrame window)
  5. locateWindow(JFrame parent, Dimension mySize, Dimension offset, JDialog me)
  6. positionFrame(final JFrame frame, final Dimension viewSize, final int addX, final int addY)
  7. resizeApp(JFrame app)
  8. restrictWindowMinimumSize(final JInternalFrame frame, final Dimension minSize)
  9. setMinMaxSizeFrame(JFrame frame)