• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

swing components size based on screen resolution

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i m developing gui with the screen resolution as 800 * 600.i have to convert the same gui to 1024 * 768 resolution.
is there any common method for solving this without changing the each components size?
anyone reply to this.
thanks in advance.
selvakkumari
 
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 manager are you using? Most layout managers can handle this situation fine. If you aren't using a layout manager... Well, now you know why you need one.
[ March 16, 2004: Message edited by: Nathan Pruett ]
 
selvakkumari paramasivam
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i didn't use any layout manager.but i used the boxlayout for arranging the components in the panel.atlast i just add the panel to contentpane.
please tell me the posible way to handle the resolution problem with this.
thanks in advance.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well i used something like this for a similar problem.. i dont know if it's the best way, but anyway here's what ive done
- i made an instance of the java.awt.Dimension class like this
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize()
Then i used relative dimensions to all the buttons and swing components i created,
e.g.
jb=new JButton();
jb.reshape(screenSize.getwidth()/2,screenSize.getLength()/4.....
seems stupid .. if someone else knows a smarter way please let us know
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by selvakkumari paramasivam:
i didn't use any layout manager.but i used the boxlayout for arranging the components in the panel.atlast i just add the panel to contentpane.
please tell me the posible way to handle the resolution problem with this.
thanks in advance.


BoxLayout wil honor preferred size of components. Instead of using setSize as final call, use pack and that should be good.
HTH,
- Manish
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic