Can someone show me a quick example? The JFrame can be empty, I just want to know how to set it's maximum size. I tried using setMaximumSize() and it doesn't work for some reason but setMinimumSize() works fine.
I tried it using a BoxLayout and even using null as a layout manager and can't get it to work. I heard that the other layout managers don't allow you to set the maximum size of a JFrame so that is why I tried it with the layouts that I did.
I tried the following code (imported the necessary classes), but it does not work...
public class MyFrame extends JFrame
{
public MyFrame()
{
super("TestFrame");
setLayout( new BoxLayout(getContentPane(), BoxLayout.X_AXIS) );
setMaximumSize( new Dimension(400,200));
setSize(300,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible( true );
}
}// end class