自定义位置
public class Swing_demo2 {

    public static void main(String[] args) {
        JFrame jframe  =new JFrame("标题");
        jframe.setDefaultCloseOperation(jframe.EXIT_ON_CLOSE);
        jframe.setSize(300,300);
        jframe.setLocation(500,300);//在屏幕中设置显示的位置
        jframe.setVisible(true);   //显示

    }

}


居中位置

   那么居中位置要不要去慢慢手动尝试呢,显然不用

public class Swing_demo2 {

    public static void main(String[] args) {
        JFrame jframe  =new JFrame("标题");
        jframe.setDefaultCloseOperation(jframe.EXIT_ON_CLOSE);
        jframe.setSize(300,300);
        jframe.setLocationRelativeTo(null);//在屏幕中居中显示
        jframe.setVisible(true);   //显示

    }

}



相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2021-09-13
  • 2022-01-26
  • 2021-07-23
相关资源
相似解决方案