CoreJava/Class/c7/CenterFrameDemo.java

24 lines
596 B
Java
Raw Permalink Normal View History

2024-05-09 09:10:51 +08:00
package Class.c7;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
public class CenterFrameDemo {
public static void main(String[] args) {
Toolkit tk =Toolkit.getDefaultToolkit();
Dimension ScreenSize = tk.getScreenSize();
int width = (int)ScreenSize.getWidth()/2;
int hight = (int)ScreenSize.getHeight()/2;
int x = width/2;
int y = hight/2;
Frame f = new Frame();
f.setTitle("CenterFrame");
f.setSize(width, hight);
f.setLocation(x, y);
f.setVisible(true);
}
}