# Wie Java-Programm zu Applet machen?!



## newnoise (23. Sep 2009)

Hallo,

ich fange gerade an eine Java-Anwendung zu entwickeln. Diese soll dann als Web-Applikation laufen.
Zum Test habe ich eben mal einen Taschenrechner mit Swing-Elementen erstellt, was auch problemlos läuft. Aber wie kann daraus nun ein Applet erstellen. Wenn ich die .jar einbinde gibts immer nen Fehler. Bei der .class auch.
Oder muss ich das als gänzlich anderes Projekt erstellen dann?

Fehlerausgabe lautet: 
	
	
	
	





```
Java Plug-in 1.6.0_14
Verwendung der JRE-Version 1.6.0_14-b08 Java HotSpot(TM) Client VM

[...]

Exception in thread "AWT-EventQueue-7" java.lang.NullPointerException
	at java.awt.LightweightDispatcher$3.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-7" java.lang.NullPointerException
	at java.awt.LightweightDispatcher$3.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-7" java.lang.NullPointerException
	at java.awt.LightweightDispatcher$3.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-7" java.lang.NullPointerException
	at java.awt.LightweightDispatcher$3.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-7" java.lang.NullPointerException
	at java.awt.LightweightDispatcher$3.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-7" java.lang.NullPointerException
	at java.awt.LightweightDispatcher$3.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
```

Gemacht habe ich das ganze mit NetBeans.

Die Tutorials die ich gefunden habe, haben mich eher mehr verwirrt ...

Danke
noise


----------



## spyboot (23. Sep 2009)

Applets kennen doch gar keine main() Methode oder?

Ansonsten im Prinzip den ganzen Code der main() in init() schmeißen dass Applet müsste dan weiß bleiben aber du hättest deinen Frame von einem Applet erstellt.

Java Applet Tutorial - Home


----------



## L-ectron-X (23. Sep 2009)

Du hast sicher die GUI-Komponenten deines Programm in einem Hauptpanel organisiert.
Dann ist es recht einfach: Schreibe eine Klasse, die von JApplet erbt und setze dieses Panel dann als einzige Komponente hinein.
Auch mal die Forumsuche benutzen, dieses Thema kam schon einige Male.


----------

