java - Sinthatica 与 JFrame 调整大小

标签 java swing jframe layout-manager

无法将 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/

相关文章:

java - 在 eclipse helios 中安装 hibernate 工具

java - 字符串数组的 UML 类图

java - Eclipse IDE 中的“设计”选项卡为空白

java - 如何在窗口监听器方法中调用 JFrame(类本身)?

java - 试图递归地找到数组中第二小的整数java

java - 如何在工具栏android中为标题设置自定义字体

java - 如何构造 JTextArea

java - 使GridBagLayout中的组件占据相同的宽度

java - java中URL截图的任何方法

java - 向 JInternalFrame 添加新类