当前位置: 代码迷 >> Java面试 >> 高手近来帮忙啊该怎么处理
  详细解决方案

高手近来帮忙啊该怎么处理

热度:211   发布时间:2016-04-17 20:43:14.0
高手近来帮忙啊
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();
  相关解决方案