• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Full screen

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What layout(s) are you using?
 
Nupur Gupta
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nate..thanks for replying.. I am using GridBagLayout...
Maybe I am not doing so correctly...hmmm
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Maneesh! It worked - it is a very big help!!!
 
I was born with webbed fish toes. This tiny ad is my only friend:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic