You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
706 B
29 lines
706 B
package com.wjr.view;
|
|
|
|
import java.awt.Toolkit;
|
|
import java.awt.event.WindowAdapter;
|
|
import java.awt.event.WindowEvent;
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
public class MyFrame extends JFrame{
|
|
|
|
private double screenWidth=Toolkit.getDefaultToolkit().getScreenSize().getWidth();
|
|
private double screenHeight=Toolkit.getDefaultToolkit().getScreenSize().getHeight();
|
|
|
|
public MyFrame(String title,int width,int heigth) {
|
|
super(title);
|
|
|
|
setSize(width,heigth);
|
|
int x=(int)(screenWidth-width)/2;
|
|
int y=(int)(screenHeight-heigth)/2;
|
|
setLocation(x,y);
|
|
|
|
addWindowListener(new WindowAdapter() {
|
|
public void windowClosing(WindowEvent e) {
|
|
System.exit(0);
|
|
}
|
|
});
|
|
}
|
|
}
|