• Post Reply Bookmark Topic Watch Topic
  • New Topic

Resize my swing application depending on screen resolution  RSS feed

 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
K. Tsang
Bartender
Posts: 3632
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!