Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swing 在Netbeans GUI中居中JInternalFrame:setLocation()不工作?_Swing_User Interface_Netbeans_Jframe_Jinternalframe - Fatal编程技术网

Swing 在Netbeans GUI中居中JInternalFrame:setLocation()不工作?

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

我正在使用Netbeans GUI创建一个桌面应用程序,我创建了一个JFrame,并使用侧面板在桌面窗格中添加了多个Internalframes。但是setLocation()方法根本不起作用。我正在将Internalframe从一个位置拖到另一个位置,以查找“桌面中心”窗格。但它没有帮助。 怎么做

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代码?因为它没有任何与居中帧相关的属性。。