下面的代码有三个错误啊,高手们帮我看看啊
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyGridLayout
{
public MyGridLayout()
{
JFrame f=new JFrame();
Container contentPane=f.getContentPane();
contentPane.setLayout(new GridLayout(10,10));
for(int i=1;i<=9;i++)
contentPane.add(new JButton(""+i));
f.setTitle("网格");
f.pack();
f.setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public static void main(String args[]){
GridLayoutDemo b=new MyGridLayoutDemo();
}
}
----------------解决方案--------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyGridLayout
{
public MyGridLayout()
{
JFrame f=new JFrame();
Container contentPane=f.getContentPane();
contentPane.setLayout(new GridLayout(10,10));
for(int i=1;i<=9;i++)
contentPane.add(new JButton(""+i));
f.setTitle("网格");
f.pack();
f.setVisible(true);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public static void main(String args[]){
MyGridLayout b=new MyGridLayout();
}
}
不知道你的GridLayoutDemo和MyGridLayoutDemo是哪里的,给你改成你代码的样子,编译成功!
----------------解决方案--------------------------------------------------------
犯这种错误太不应该了,以后小心点
----------------解决方案--------------------------------------------------------