Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Resize my swing application depending on screen resolution

 
Ranch Hand
Posts: 499
Spring AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I developed a swing application using group layout. It resizes when I resize the frame but when I change the screen resolution or when I run the application in a laptop which has small sized screen, the components over lap each other. I need my application to fit according to the screen resolution

Sorry to upload netbeans generated code, my code is in office. The code is as follows



According to the list item selected, an internal frame will appear in the desktop pane. I use group layout for that internal frame too.
Screenshot-from-2014-09-26-23-04-35.png
[Thumbnail for Screenshot-from-2014-09-26-23-04-35.png]
Screen shot of designed frame
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser 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 java.awt.Toolkit, it has a getScreenSize() method. With that you can adjust the default app window on launch accordingly or something.

Once app is opened, resizing the window is another thing I think.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Partheban Udayakumar wrote:... when I run the application in a laptop which has small sized screen, the components over lap each other. I need my application to fit according to the screen resolution



You can't put a quart of beer in a pint bottle. IOW, you have to design your GUI for the lowest resolution on which the program may need to be run. And this is true of any GUI platform; it's not unique to Java or GroupLayout.

If you have the time and energy, you could develop different versions of the UI and have the program decide, based on K Tsang's advice, which one to launch. Or you can encase the whole shebang in a JScrollPane and let users of small screens keep scrolling.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
Spring AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

K. Tsang wrote:Take a look at java.awt.Toolkit, it has a getScreenSize() method.



Yes. I know that its



I tried using percentages of frame size say for example the button width as



Is this approach correct?

Darryl Burke wrote: IOW, you have to design your GUI for the lowest resolution on which the program may need to be run.



I tried that but with greater screen resolution, the UI looks too small and my people want it to look the same in every resolution.
 
Popeye has his spinach. I have this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic