Launch Java applets directly (without html page)

I have a problem.

How can I run my java applet directly without the built-in in my web page?

I know that appletViewr can execute an applet without a browser, but I need to get a java applet without an html page.

+5
source share
7 answers

Appletviewer is the way BUT, it still needs a webpage with the applet-tag .

An alternative solution is a class stub entry to the main method that creates an instance of the applet, causes init(), start(), stop()and destroy(), as it would otherwise be done by the browser or applet.

+4
source

, AppletClass - Applet.

AppletClass appletClass = new AppletClass ();

JFrame frame = new JFrame();
frame.setLayout(new GridLayout(1, 1));
frame.add(appletClass );

// Set frame size and other properties
...

// Call applet methods
appletClass .init();
appletClass .start();

frame.setVisible(true);

.

+4

appletviewer [ options ] urls ...

+1

, , init(), start(), stop(), .

+1

eclipse: java (, ), " " "".

+1

Use /*<applet code="java file name " height=150 width=150></applet>*/ before declaring the applet class, and then compile the java program and run the applet using the appletviewer, which it performs fine, does not require any html file

+1
source
<applet code=classname height=200 width=200>

</applet>

Just write this code in your Java program and run it first using:

javac classname.java

after

run:appletviewer classname.java
-1
source

All Articles