import java.awt.*;
import java.awt.event.*;
public class Paintframe { public static void main(String[] args) {
new MyFrame("t",200,300,500,600); }}class MyFrame extends Frame{
MyFrame(String s,int x,int y,int w,int h){
super(s);
Panel p1=new Panel(null);
Panel p2 = new Panel(null);
Panel p3 = new Panel(null);
Panel p4 = new Panel(null);
p1.setBackground(Color.CYAN);
p2.setBackground(Color.blue);
p3.setBackground(Color.DARK_GRAY);
p4.setBackground(Color.PINK);
p1.setBounds(0, 0, w/2, h/2);
p2.setBounds(0, h/2, w/2, h/2);
p3.setBounds(w/2, 0, w/2, h/2);
p4.setBounds(w/2, h/2, w/2, h/2);
add(p1);
add(p2);
add(p3);
add(p4);
addWindowListener(new WindowAdapter(){
public void WindowClosing(WindowEvent e){
setVisible(false);
System.exit(0);
}
});
setBackground(Color.green);
setBounds(x, y,w, h);
setVisible(true);
}
这在我机子上关不掉!请指出问题,谢谢!
import java.awt.event.*;
public class Paintframe { public static void main(String[] args) {
new MyFrame("t",200,300,500,600); }}class MyFrame extends Frame{
MyFrame(String s,int x,int y,int w,int h){
super(s);
Panel p1=new Panel(null);
Panel p2 = new Panel(null);
Panel p3 = new Panel(null);
Panel p4 = new Panel(null);
p1.setBackground(Color.CYAN);
p2.setBackground(Color.blue);
p3.setBackground(Color.DARK_GRAY);
p4.setBackground(Color.PINK);
p1.setBounds(0, 0, w/2, h/2);
p2.setBounds(0, h/2, w/2, h/2);
p3.setBounds(w/2, 0, w/2, h/2);
p4.setBounds(w/2, h/2, w/2, h/2);
add(p1);
add(p2);
add(p3);
add(p4);
addWindowListener(new WindowAdapter(){
public void WindowClosing(WindowEvent e){
setVisible(false);
System.exit(0);
}
});
setBackground(Color.green);
setBounds(x, y,w, h);
setVisible(true);
}
这在我机子上关不掉!请指出问题,谢谢!
是public void windowClosing(WindowEvent e)
你把windowClosing写成WindowCLosing了
不对吧,应该是把windowClosing写成了WindowClosing