Java JFrame Size according to screen resolution

后端 未结 7 1820
[愿得一人]
[愿得一人] 2020-12-09 17:48

I created java GUI using myEclipse Matisse. when my Screen Resolution is 1024x768 it works fine but when i change resolution my GUI is not working fine. I want my GUI window

相关标签:
7条回答
  • 2020-12-09 18:24

    First, setbounds for frame then remove pack() method.

    0 讨论(0)
  • 2020-12-09 18:25

    Try this... Select all components of JFrame, right click, select 'Auto Resizing', check for both Horizontal and Vertical, close .

    0 讨论(0)
  • 2020-12-09 18:27

    You can try using this to maximize the frame:

    this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    
    0 讨论(0)
  • 2020-12-09 18:37

    Calling pack() is vital to a correctly functioning GUI. Call it after all the components have been added, to have it validate the container and set it to it's natural size.

    Then call setSize() & related methods like setBounds() afterwards.

    0 讨论(0)
  • 2020-12-09 18:41

    Calling pack() will usually result in the window being resized to fit the contents' preferred size. Try removing the call to pack() and see what happens.

    0 讨论(0)
  • 2020-12-09 18:48

    You are calling pack() which changes the frame size so it just fits the components inside. That's why it is shrinking back I think. Remove the pack() line and it should work.

    0 讨论(0)
提交回复
热议问题