I have written a swing application using a JFrame and now realise it should have been in full screen mode. But resizing it now is going to cause all the components to go haywire... is there any way I can use full screen maintaining my current proportions?
Why do you want to make a full-screen-mode application resizable? Doesnt make sense. Also it is a bad usability design.
I would recommend the following: 1) Launch in full screen mode (Default) 2) Provide the user with an option of toggling between full screen and non full screen mode. 3) Once the user enters the non full screen mode, s/he can always resize the window.
I think that applications should resize well whether you plan to use them in full screen mode or in a resizeable frame - then you won't run into problems when you decide to switch between the two - or when users with different screen sizes/resolutions use your application.
GridBagLayout can do this - but make sure you are using use weightx, weighty, and fill - these tell GridBagLayout how to distribute "extra" space in the layout.
Joined: Aug 02, 2006
It's not about resizing....I had coded the application to run in a smaller screen....now if I set it to large full screen..everything goes haywire....e.g. I had just two rows..now 2 rows take up the whole screen...and it just looks plain bad. Thanks so much for your help
//code to initialize GridBagConstraints(gbc) and set various parameters //Code to add whatever components need to be added
//Now do this gbc.weightx=1.0; gbc.weighty=1.0; gbc.gridy++; yourContainer.add(new JLabel(" "),gbc);
This will push your components to the top of the container. Whenever the component is resized on the plus side, the extra space will be taken up with the empty JLabel(" ");
Best of luck
Joined: Aug 02, 2006
Hi, Thanks a LOT for your help. However , it is not working.. I don't quite understand. So this is what I have done...
I have a JFrame, to which is added a JPanel(tsPanel). The Grid Layout of tsPanel is set, and I add some components to it. After each component, I add
gbc.weightx=1.0; gbc.weighty=1.0; gbc.gridy++; JLabel test = new JLabel(" "); gbl.setConstraints(test, gbc); tsPanel.add(test,gbc);
So next, I open my frame, and I resize it to occupy the full screen(I am not yet using the Java APIs to set full screen mode). I find that my components have gone awry, that is the size and orientation that I had in my un-resized window is not maintained. Any pointers? Would be much appreciated. Thanks