Automatic user interface customization based on screen size, user interface in java swing

I am working on software that runs on monitors with different screen sizes from laptop screens to TV screens. I would like to know about the java swing function, which automatically adjusts the component relative to the screen size

+5
source share
3 answers

the following code will return the width and height of the screen

Toolkit toolkit =  Toolkit.getDefaultToolkit ();
Dimension dim = toolkit.getScreenSize();
frame.setSize(dim.width,dim.height);//here frame is your container 
+4
source

You can use the ToolKit , but its always best to have half the width and height of the screen .

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

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

myframe.setSize( w/2 , h/2 );
+3
source

U-turn layouts are what you are looking for: http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html

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

Fill the components using the layout, and then run the application in full screen.

+2
source

All Articles