1

i have been working on a Swing application that has a JFrame as principal Frame and it contains a lot of JInternalFrames inside of it , and when i installed it in every computer in the company, it seems that some computers screen size is lower and more tight then the screen in wish i had developed my application, and that is not useful, so i am asking if i can adjust my application (Frames) to every kind of screen size, i am using Swing API.

Thank you.

user1329572
  • 6,176
  • 5
  • 29
  • 39
Zakaria Marrah
  • 755
  • 6
  • 15
  • 28
  • 1
    In addition to the options shown here suggest you always use a layout. Do not leave your screen without layout (setLayout(null)) because if you don't use layout might impact on different operating systems. – matheuslf Nov 29 '12 at 16:07

2 Answers2

5

You can check the size of the screen like this:

 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

Then you can decide how much of the screen you want to cover. Say half the size of the screen.

 int h = screen.height / 2;
 int w = screen.width / 2;

Then set your JFrame to this new height and width.

myFrame.setSize(new Dimension(w, h));

Of course you will have to experiment a bit to see what size works for all your screen sizes. Alternatively you can simply maximise the Frame on start up.

Vincent Ramdhanie
  • 102,349
  • 23
  • 137
  • 192
1

you can get the local maximum resolution with

GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Rectangle desktopBounds = env.getMaximumWindowBounds();

then you can adjust your application accordingly note that this is in AWT but for me it still got the right result

schippi
  • 1,034
  • 5
  • 15