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.

Resizing JFrame Window messes up the contents of the window

user13731090Mar 1 2012 — edited Mar 2 2012
Hello All,

I have a Jaframe Window and the content of this window are 2 panels,
1. JPanel which contains another panel and is using GridBagLayout
2. JPanel which is a status panel

so my code could be summerized to..

JPanel mainPanel = new JPanel(GridBagLayout());
JPanel dataPanel = new JPanel();
mainPanel.add(DataPanel, c);

JPanel statusPanel = new JPanel()

frame.getContentPane.add(mainPanel, BorderLayout.CENTER);
frame.getContentPane.add(statusPanel, BorderLayout.SOUTH);

Everything works fine,
I have not deliberately added a scrollpane to the window, because i dont want to see the scroll bars, that is a requirement for the application, user does not want scroll bars.
When the window resizes, i need to scale my data panel and it is working fine.

But the problem is, when i click on the window border, for resizing the window, my data panel get shifted so that i see only top left portion of the data panel.
But after i am done with resizing the window, i have placed code to put the data panel in the center of the window and that is working fine.

But the problem is when i click on the window border to resize, it messes up the data panel, shifts it and it is not even visible completely.
I read about continuous layout and tried to turn it off, but Window resize gets messy when window sizze is bigger than my content panel.

Please advice what do i need to do here inorder to stop the contents of my data panel shifting to some place when i click ont he window border, inorder to resize the window.

Any help is appreciated.
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 30 2012
Added on Mar 1 2012
8 comments
1,709 views