Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JFrame.setResizable(false) changes the size of the window

843807Oct 11 2009 — edited Feb 26 2010
I'm having troubles with the call to setResizable(false) adding an extra 10 pixels or so to the height and width of my JFrame. This frame needs to have its internal area precisely sized because it is going to display a JPanel which draws an image of a precise size.

Below is the code I'm using. If I leave out the call to setResizeable(), my panel is drawn at the correct size. If I use the call, immediately afterward the frame will have gained extra pixels. I've tried putting the call to setResizable() in several places, but nothing works. How can I stop this call from adding a gap to my window?

This is happening on Windows Vista.
public class SwingFrame extends JFrame
{
    JPanel panel = new MyPanel();

    public SwingFrame(Config config)
    {
        setResizable(false);
        panel.setPreferredSize(new Dimension(320, 240));
        add(panel);
        pack();
    }
}
Edited by: Mark_McKay on Oct 11, 2009 4:58 AM

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 26 2010
Added on Oct 11 2009
7 comments
1,983 views