JButton.setBounds(x,y,w,h) doesn't seem to work

谁说我不能喝 提交于 2019-12-02 01:35:37

Your frame is under the control of a layout manager, it is making the decisions on how best to layout your components and is overriding the values you have specified using setBounds

Modern GUIs need to run (even on the same OS) in a variety of different graphical environments, including different DPI, screen sizes and font settings for example.

The layout manager makes it possible for you to worry (less) about these issues and it is highly recommended that you make use of them

Take a look at

For more details

pundit

As a good practice, you should not add the button directly to the JFrame. Instead, add a JPanel to the frame, set the panel's layout to null, and add the JButton to the JPanel.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!