标签:cat vax out swing code tle getheight int window
创建一个新窗口,通过getSize()获取这个窗口的宽、高。
1 import javax.swing.JFrame; 2 3 public class WindowInTheMiddle extends JFrame { 4 5 6 public static void main(String[] args) { 7 WindowInTheMiddle window = new WindowInTheMiddle(); 8 window.launchFrame(); 9 10 // Width & Height 11 System.out.println(window.getSize().getWidth()); 12 System.out.println(window.getSize().getHeight()); 13 } 14 15 public void launchFrame() { 16 this.setTitle("Hello World! I‘m coming!"); 17 this.setSize(500, 500); 18 this.setLocation(300, 300); 19 this.setVisible(true); 20 } 21 }
标签:cat vax out swing code tle getheight int window
原文地址:https://www.cnblogs.com/Satu/p/9829317.html