0

I am currently trying to code my program that uses a JFrame and JPanel so that if the user tries to re-size the Frame smaller than the Panel the program won't allow that to happen. I've been researching for a while now using and got it working a little bit with a ComponentListener however I need to code it using a user-defined exception. Below is the code I used for the ComponentListener. Could anyone give me advice on how to do this via a User-Defined exception?

Frame.addComponentListener(new ComponentAdapter() 
{
    public void componentResized(ComponentEvent e) 
    {
        Frame.setSize(Math.min(800,
        Frame.getWidth()),
        Math.min(350,
        Frame.getHeight()));
    }
});
Raidri
  • 17,258
  • 9
  • 62
  • 65
user1839601
  • 119
  • 1
  • 9

1 Answers1

0

Swing supports preventing users from resizing with the setMinimumSize function on JFrame.

See Setting minimum size limit for a window in java swing

Community
  • 1
  • 1
Garrett Hall
  • 29,524
  • 10
  • 61
  • 76