Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

swing components size based on screen resolution

 
selvakkumari paramasivam
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Sammer Meer
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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
 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic