Swing 在Netbeans GUI中居中JInternalFrame:setLocation()不工作?
我正在使用Netbeans GUI创建一个桌面应用程序,我创建了一个JFrame,并使用侧面板在桌面窗格中添加了多个Internalframes。但是setLocation()方法根本不起作用。我正在将Internalframe从一个位置拖到另一个位置,以查找“桌面中心”窗格。但它没有帮助。 怎么做Swing 在Netbeans GUI中居中JInternalFrame:setLocation()不工作?,swing,user-interface,netbeans,jframe,jinternalframe,Swing,User Interface,Netbeans,Jframe,Jinternalframe,我正在使用Netbeans GUI创建一个桌面应用程序,我创建了一个JFrame,并使用侧面板在桌面窗格中添加了多个Internalframes。但是setLocation()方法根本不起作用。我正在将Internalframe从一个位置拖到另一个位置,以查找“桌面中心”窗格。但它没有帮助。 怎么做 public class HomeForm extends javax.swing.JFrame { /** * Creates new form HomeForm */ public Ho
public class HomeForm extends javax.swing.JFrame {
/**
* Creates new form HomeForm
*/
public HomeForm() {
initComponents();
setExtendedState(MAXIMIZED_BOTH);
jInternalFrame2.setLocation(GetScreenWorkingWidth()/3-50 , GetScreenWorkingHeight()/3-150);
jInternalFrame2.setVisible(false);
jInternalFrame2.setVisible(false);
}
public static int GetScreenWorkingWidth()
{
return java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
}
public static int GetScreenWorkingHeight()
{
return java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
}
}
我正在使这些内部框架在点击按钮时可见 如果您正在使用GUI builder,为什么要编写GUI代码?因为它没有任何与居中帧相关的属性。。