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