This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Full screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Full screen" Watch "Full screen" New topic
Author

Full screen

Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
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?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

What layout(s) are you using?


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
Nate..thanks for replying.. I am using GridBagLayout...
Maybe I am not doing so correctly...hmmm
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

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.
Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
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
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

As Nathan correctly pointed out, this is the GridBagConstraints issue.
Try this:

//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
Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
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
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Take a look at this sample code. Notice my comments inline. Your mistake was that you added the JLabel after every component.

Best of luck

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Take a look at this sample code. Notice my comments inline. Your mistake was that you added the JLabel after every component.

Best of luck

Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
Thank you so much Maneesh! It worked - it is a very big help!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Full screen
 
Similar Threads
Full Screen on Maximize
c++ not running fullscreen in windows seven?
Creating my first game
Screen size for laptop
how to come back the previous screen