public class Test extends JApplet
{
TestEventID = 23456;//be careful to set this ID
TestPanel tp = new TestPanel();
...
public void sendTestMessage()
{
ActionEvent ae =new ActionEvent(viewPage,TestEventID,"A test event");
tp.dispatchEvent(ae);
}
}
Class TestPanel extends JPanel
{
TestEventID = 23456;//be careful to set this ID
...
public void processEvent(AWTEvent awte)
{
if(awte.getID()==TestEventID)
{
try
{
Thread.sleep(5000);
System.out.println("processEvnt finished");
}
catch(InterruptedException ie)
{}
}
else
super.processEvent(awte);
}//end of processEvent
}
{
TestEventID = 23456;//be careful to set this ID
TestPanel tp = new TestPanel();
...
public void sendTestMessage()
{
ActionEvent ae =new ActionEvent(viewPage,TestEventID,"A test event");
tp.dispatchEvent(ae);
}
}
Class TestPanel extends JPanel
{
TestEventID = 23456;//be careful to set this ID
...
public void processEvent(AWTEvent awte)
{
if(awte.getID()==TestEventID)
{
try
{
Thread.sleep(5000);
System.out.println("processEvnt finished");
}
catch(InterruptedException ie)
{}
}
else
super.processEvent(awte);
}//end of processEvent
}
要用protected.
不用监听、enable,就是该方法过时了!尽管如此,大家这么热心,我开始给分了!