您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Content Index

Content Page # 12

Converting an applet to an application

It is very straightforward to convert an applet to a stand-alone application. Remember that the ‘ add() ’ method can add any Java user interface element to a window. An applet is simply an object of Applet class, so we can add() an applet to a Frame very easily. Suppose we have an applet called MyApplet’ and we wish it to be inside the main window of an application. All that needs to be done is to add the following line to the main window’s constructor:

add(new MyApplet());

Since we already have a do-nothing application ( DoNothing.java ), we can use this to form the main window for an applet, and therefore convert any applet into an application. Note that it is not necessary to change the applet at all for this to work.

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg