主题:[原创]都是同样的问题
public class e11_9 implements ActionListener
{
public e11_9( )
{
JFrame f=new JFrame("这是一个JFrame");
Container cp=f.getContentPane( );
JButton bt1=new JButton("北部"),
bt2=new JButton("西部"),
bt3=new JButton("东部"),
bt4=new JButton("南部");
JLabel lb1=new JLabel("中部");
cp.add("North",bt1);
bt1.addActionListener(this);
cp.add("West",bt2);
bt2.addActionListener(this);
cp.add("East",bt3);
bt3.addActionListener(this);
cp.add("South",bt4);
bt4.addActionListener(this);
cp.add("Center",lb1);
f.pack( );
f.show( );
f.addWindowListener(new WinLis( ));
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource( )==bt1)
{
lb1.setText("按钮1");
}
else if(e.getSource( )==bt2)
{
lb1.setText("按钮2");
}
else if(e.getSource( )==bt3)
{
lb1.setText("按钮3");
}
else
{
lb1.setText("按钮4");
}
}
public static void main(String[ ] arg)
{
new e11_9( );
}
class WinLis extends WindowAdapter
{
public void windowsClosing(WindowEvent e)
{
System.exit(0);
}
}
}
它却给我一个错误:
cannot resolve symbol variable bt1
cannot resolve symbol variable lb1
cannot resolve symbol variable bt2
cannot resolve symbol variable lb1
cannot resolve symbol variable bt3
cannot resolve symbol variable lb1
为什么????
请求高手解答~~~~~~~~
{
public e11_9( )
{
JFrame f=new JFrame("这是一个JFrame");
Container cp=f.getContentPane( );
JButton bt1=new JButton("北部"),
bt2=new JButton("西部"),
bt3=new JButton("东部"),
bt4=new JButton("南部");
JLabel lb1=new JLabel("中部");
cp.add("North",bt1);
bt1.addActionListener(this);
cp.add("West",bt2);
bt2.addActionListener(this);
cp.add("East",bt3);
bt3.addActionListener(this);
cp.add("South",bt4);
bt4.addActionListener(this);
cp.add("Center",lb1);
f.pack( );
f.show( );
f.addWindowListener(new WinLis( ));
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource( )==bt1)
{
lb1.setText("按钮1");
}
else if(e.getSource( )==bt2)
{
lb1.setText("按钮2");
}
else if(e.getSource( )==bt3)
{
lb1.setText("按钮3");
}
else
{
lb1.setText("按钮4");
}
}
public static void main(String[ ] arg)
{
new e11_9( );
}
class WinLis extends WindowAdapter
{
public void windowsClosing(WindowEvent e)
{
System.exit(0);
}
}
}
它却给我一个错误:
cannot resolve symbol variable bt1
cannot resolve symbol variable lb1
cannot resolve symbol variable bt2
cannot resolve symbol variable lb1
cannot resolve symbol variable bt3
cannot resolve symbol variable lb1
为什么????
请求高手解答~~~~~~~~