高手近来帮忙啊
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ButtonTest extends JFrame{
private JButton plainButton,fancyButton;
public ButtonTest(){
super( "Testing Buttons ");
Container container=new getContentPane();
container.setLayout(new FlowLayout());
plainButton=new JButton( "Plain Button ");
container.add(plainButton);
fancyButton=new JButton( "Fancy Button ");
container.add(fancyButton);
ButtonHandler handler=new ButtonHandler();
fancyButton.addActionListener(handler);
plainButton.addActionListener(handler);
setSize(275,100);
setVisible(true);
}
public static void main(String args[]){
ButtonTest application=new ButtonTest();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent event){
JOptionPane.showMessageDialog(ButtonTest.this, "You pressed: "+event.getActionCommand());
}
}
}
编译后提示Container container=new getContentPane();不对,错在哪里了?希望高人指导一下
------解决方案--------------------Container container=this.getContentPane();