Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto adjusting of UI based on screen size,UI in java swing

I work on a software that runs in monitors of different screen size from laptop screens to TV screens.I would you to know about java swing feature that auto-adjust the component relatively according to screen size

like image 406
coderaider Avatar asked Jun 29 '12 05:06

coderaider


3 Answers

the following code will returns the screen width and height

Toolkit toolkit =  Toolkit.getDefaultToolkit ();
Dimension dim = toolkit.getScreenSize();
frame.setSize(dim.width,dim.height);//here frame is your container 
like image 170
padman Avatar answered Sep 21 '22 05:09

padman


You can use ToolKit, but its always better to have have Half the screen Width and Height.

Toolkit t = Toolkit.getDefalutToolKit();
Dimension d = t.getScreenSize();

int h = d.height;
int w = d.width;

myframe.setSize( w/2 , h/2 );
like image 45
Kumar Vivek Mitra Avatar answered Sep 19 '22 05:09

Kumar Vivek Mitra


Swing layouts are the thing you are looking for: http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html

There are types of layouts that dynamically rearranges the components according to the application size. You can see options for layout in the link I gave above.

Fill in the components using layout and than make your application run fullscreen.

like image 40
bmkorkut Avatar answered Sep 22 '22 05:09

bmkorkut