日期:2014-05-20  浏览次数:20788 次

请高手来帮我运行一下按扭事件,我的运行是个空面板!
package   yan1;
import   javax.swing.*;
import   java.awt.*;
import   java.awt.event.*;
class   paneltest   extends   JApplet
{JPanel   panelobj;
  public   paneltest(){
  panelobj=new   JPanel();
    getContentPane().add(panelobj);
}
}
class   buttontest   extends   paneltest{
    JButton   buttonobj1;
    JButton   buttonobj2;
public   buttontest(){
      buttonobj1=new   JButton( "ji   wo ");
      buttonobj2=new   JButton( "an   niou   2 ");
      buttonobj1.setEnabled(true);
      buttonobj2.setEnabled(false);
      panelobj.add(buttonobj1);
      panelobj.add(buttonobj2);
}
}
class   flowlayout   extends   buttontest{
    FlowLayout     layoutobj;
  public   flowlayout(){
  layoutobj=new   FlowLayout(   FlowLayout.CENTER,10,10);
  panelobj.setLayout(layoutobj);

  }
}
class   eventest   extends   flowlayout
{
      ButtonEvent1   beobj1;
      ButtonEvent2   beobj2;
      public   eventest()
  {   beobj1=new   ButtonEvent1();
    beobj2=new   ButtonEvent2();
    buttonobj1.addMouseListener(beobj1);
    buttonobj2.addMouseListener(beobj2);
  }
  class   ButtonEvent1   extends   MouseAdapter
{  
   
  public   void   mouseClicked(MouseEvent   e)  
  {  
      buttonobj1.setEnabled(false);
      buttonobj1.setText( "AN   NIOU   1 ");
      buttonobj1.setEnabled(true);
      buttonobj2.setText( "ji   wo ");

    }
 
   
  }
  class   ButtonEvent2   extends   MouseAdapter
  {  
  public   void   mouseClicked(MouseEvent   e)  
  {   buttonobj2.setEnabled(false);
            buttonobj2.setText( "an   niou   2 ");
            buttonobj1.setEnabled(true);
            buttonobj1.setText( "ji   wo ");
          }
   
        }
}

public   class   Yan2   {
        public   void   init(){
          new   eventest();
 

        }

}
我的QQ为378761266请加我!!
错误提示为
java.lang.IllegalAccessException:   Class   sun.applet.AppletPanel   can   not   access   a   member   of   class   yan1.paneltest   with   modifiers   "public "
at   sun.reflect.Reflection.ensureMemberAccess(Unknown   Source)
at   java.lang.Class.newInstance0(Unknown   Source)
at   java.lang.Class.newInstance(Unknown   Source)
at   sun.applet.AppletPanel.createApplet(Unknown   Source)
at   sun.applet.AppletPanel.runLoader(Unknown   Source)
at   sun.applet.AppletPanel.run(Unknown   Source)