Java Insets获取窗口的顶、底、左、右的大小

import java.awt.Insets;

import javax.swing.JFrame;

public class NewFrame {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(500, 500);
frame.setVisible(true); Insets insets = frame.getInsets();
System.out.println(insets.top);
System.out.println(insets.bottom);
System.out.println(insets.left);
System.out.println(insets.right);
}
}
 import java.awt.Insets;

 import javax.swing.JFrame;

 public class NewFrame extends JFrame {

     public void launchFrame() {
this.setSize(500, 500);
this.setLocation(300, 300);
this.setVisible(true);
} public static void main(String[] args) {
NewFrame nf = new NewFrame();
nf.launchFrame(); Insets insets = nf.getInsets();
System.out.println(insets.top);
System.out.println(insets.bottom);
System.out.println(insets.left);
System.out.println(insets.right);
}
}
上一篇:OpenACC 计算规约时发现的小坑


下一篇:把指定的字符串翻译成 pig latin。