public class Test2
{
public static void main(String[] args)
{
new MyFrame();
}
}
class MyFrame
{
JLabel lab = new JLabel();
MyFrame()
{
JFrame f = new JFrame("MyFrame");
f.setLayout(new BorderLayout());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
f.setBounds(120,100,200,230);
JButton btn = new JButton();
btn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
lab.setText("success!");//这里没有了错误提示 }
});