24 lines
596 B
Java
24 lines
596 B
Java
|
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);
|
||
|
|
||
|
}
|
||
|
}
|