import javax.swing.JFrame;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.Dimension;
class SampleJFrame extends JFrame{
SampleJFrame(){
super("java 示例框架窗口");
setSize(500,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
Image appIcon;
Toolkit tkit=Toolkit.getDefaultToolkit();
appIcon=tkit.getImage("F:\\Picture\\1.JPEG");
setIconImage(appIcon);
Dimension screenSize=tkit.getScreenSize();
Dimension frameSize=this.getSize();
if(frameSize.height>screenSize.height){
frameSize.height=screenSize.height;
}
if(frameSize.width>screenSize.width){
frameSize.width=screenSize.width;
}
this.setLocation((screenSize.width-frameSize.width)/2,(
ScreenSize.height-frameSize.height)/2);
setVisible(true);
}
public static void main (String[] args){
SampleJFrame sjf=new SampleJFrame();
}
}