开发者

Calling a class in the Main()

I have written a class that is an applet and doesn't contain a main(). Is there any possible way for me to just pass the entire class to main to run it because I can't call all the methods through开发者_开发问答 main, I just use so many things it's impossible.

public static void main(String[] args){ }
public class Travel extends Applet implements MouseListener{
}

It seems Applets don't run main().


This hybrid demo can not only be run as either an applet or application, but be launched direct from the command line using the source in the applet viewer.

E.G.

prompt> javac HybridApplet.java
prompt> java HybridApplication // Note the 'Application'
prompt> appletviewer HybridApplet.java // Note the '.java'

Exiting the applet in the browser should redirect to the source. It will have no effect in the applet viewer. Applet viewer does not support showDocument(), unlike Appleteer, which does ;).


Edit: Note though, that many things designed as applets leverage methods & classes useful to applets - getClip(), getDocumentBase()..

These are for convenience and mostly have equivalents in other non-applet classes.


Create a main method in your applet class and instantiate it from within the main method. If you really want to run the applet though, I suggest using the appletviewer

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜