gpt4 book ai didi

java - Sinthatica 与 JFrame 调整大小

转载 作者:行者123 更新时间:2023-12-01 13:56:02 25 4
gpt4 key购买 nike

无法将 JPanel 置于运行模式和 sinthatica 主题的中心。它不居中。没有 Syntatica 主题它就可以工作。有什么问题吗?

我的代码:

//center code
TAB_PANEL1.setLocation((this.getWidth() - TAB_PANEL1.getWidth()) / 2,TAB_PANEL1.getX());

提前致谢!

最佳答案

TAB_PANEL1.setLocationRelativeTo(null);

http://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#setLocationRelativeTo%28java.awt.Component%29

If the component is null, or the GraphicsConfiguration associated with this component is null, the window is placed in the center of the screen. The center point can be obtained with the GraphicsEnvironment.getCenterPoint method.

关于java - Sinthatica 与 JFrame 调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19622492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com