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
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 ]
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Mar 16, 2004
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.
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
Ai no corrida..That's where I am<br />You send me there<br />Your dream is my command...
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
subject: swing components size based on screen resolution