zoukankan      html  css  js  c++  java
  • java swing 窗口在屏幕中默认显示的位置 居中位置显示

    自定义位置
    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);   //显示
    
        }
    
    }
    



    鲜花会生锈,盐巴会腐烂
  • 相关阅读:
    sudo命令 sudoers文件
    sscanf函数
    printf格式化输出
    c文件操作
    string和char*
    c去除空格 小写转大写
    主机序和网络序转换
    ulimit用法
    mysql基础(附具体操作代码)
    ES6 class
  • 原文地址:https://www.cnblogs.com/hunterxing/p/9709306.html
Copyright © 2011-2022 走看看