一个入门问题
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class SimpleTest{
public static void main(String []args){
FrameTest frame=new FrameTest();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show(); }
}
class FrameTest extends JFrame{
public FrameTest(){Toolkit kit=Toolkit.getDefaultToolkit();
Dimension screenSize=kit.getScreenSize();
int screenHeigth=(int)screenSize.height;
int screenWigth=(int)screenSize.width;
setSize(screenWigth/2,screenHeigth/2);
setLocation(screenWigth/4,screenHeigth/4);
Image img=kit.getImage( "abc.gif ");
setIconImage(img);
setTitle( "CenteredFrame ");
NotHelloWorldPanel panel=new NotHelloWorldPanel();
add(panel);
}
}
class NotHelloWorldPanel extends JPanel{
public void paintComponet(Graphics g){
super.paintComponent(g);
g.drawString( "not a helloworldprogram ",MESSAGE_X,MESSAGE_Y);
}
private int MESSAGE_X=100;
private int MESSAGE_Y=100;
&