当前位置: 技术问答>java相关
JApplet执行顺序问题
来源: 互联网 发布时间:2014-12-28
本文导语: public class MApplet extends JApplet { CardLayout cardLayout1 = new CardLayout();//1 Login loginManage;//2 //Construct the applet//3 public MAApplet() { } //Initialize the applet public void init() //4 {...
public class MApplet extends JApplet {
CardLayout cardLayout1 = new CardLayout();//1
Login loginManage;//2
//Construct the applet//3
public MAApplet() { }
//Initialize the applet
public void init() //4
{ LoginManage = new LoginManage(); }//5
//Start the applet
public void start() { }//6
//Stop the applet
public void stop() { }//7
//Destroy the applet
public void destroy(){ }//8
}
请问:执行顺序是否为:2-3-1-4-5-6-7-8,if not,should be???
另外:是否不管写的顺序如何,init均在start前执行?(如start()写在init()前)
CardLayout cardLayout1 = new CardLayout();//1
Login loginManage;//2
//Construct the applet//3
public MAApplet() { }
//Initialize the applet
public void init() //4
{ LoginManage = new LoginManage(); }//5
//Start the applet
public void start() { }//6
//Stop the applet
public void stop() { }//7
//Destroy the applet
public void destroy(){ }//8
}
请问:执行顺序是否为:2-3-1-4-5-6-7-8,if not,should be???
另外:是否不管写的顺序如何,init均在start前执行?(如start()写在init()前)
|
资料:
The life cycle methods of an applet are init(), start(), stop(), and destroy(). While frequently grouped with the methods, the paint() method is not really part of the applet's life cycle. The method is just called by the browser whenever a part of the screen has become invalidated or in response to a programmer-generated repaint request. The update() method falls into the same category as paint().
As far as the other methods go:
init() - called once when applet is loaded
start() - called every time the page the applet is located on is loaded, after init() or after leaving the page and returning
stop() - called every time the page the applet is located on is left
destroy() - called when applet is unloaded
If loading a serialized version of an applet from a .ser file (OBJECT attribute in tag instead of CODE attribute), the init() method is not called.
Use the start() / stop() method pair to deal with starting and stopping threads, as when the page isn't active it isn't nice to use up resources.
Don't rely on the destroy() method being called to free a crucial resource, in case the browser crashes.
I had heard that start() / stop() were called for iconifying and deiconifying, but a test with the latest browser versions shows they aren't called.
The life cycle methods of an applet are init(), start(), stop(), and destroy(). While frequently grouped with the methods, the paint() method is not really part of the applet's life cycle. The method is just called by the browser whenever a part of the screen has become invalidated or in response to a programmer-generated repaint request. The update() method falls into the same category as paint().
As far as the other methods go:
init() - called once when applet is loaded
start() - called every time the page the applet is located on is loaded, after init() or after leaving the page and returning
stop() - called every time the page the applet is located on is left
destroy() - called when applet is unloaded
If loading a serialized version of an applet from a .ser file (OBJECT attribute in tag instead of CODE attribute), the init() method is not called.
Use the start() / stop() method pair to deal with starting and stopping threads, as when the page isn't active it isn't nice to use up resources.
Don't rely on the destroy() method being called to free a crucial resource, in case the browser crashes.
I had heard that start() / stop() were called for iconifying and deiconifying, but a test with the latest browser versions shows they aren't called.
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。