This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes Trying to run applet in JEditor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Trying to run applet in JEditor" Watch "Trying to run applet in JEditor" New topic
Author

Trying to run applet in JEditor

Anthony Schmitt
Ranch Hand

Joined: Nov 17, 2009
Posts: 37
I'm attempting to place an open source applet that displays an SSH terminal (very nice piece of software called JTA) into my application. However, when I run my program I simply get an empty gray box where the internal editor frame is.

Here is my JInternalFrame:



Here is my Applet.class. I noticed it seems to have it's own init(), start(), stop(), etc., so I'm thinking if I can just call it correctly I don't need to init() or start() in my JInternalFrame, which is why I left them out.



Anyone have an idea about why my InternalJFrame isn't showing my applet?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I'm confused. Is de.mud.jta.Applet your class, or the one you found elsewhere? If you found it elsewhere it should come with its own methods that you should leave alone. If it's your class, then which class are you trying to run?

http://www.acme.com/resources/classes/Acme/MainFrame.java can help you run an applet as part of an application.
Anthony Schmitt
Ranch Hand

Joined: Nov 17, 2009
Posts: 37
de.mud.jta.Applet is part of the JTA .jar. My understanding of it is that de.mud.jta.Applet does a lot of the stuff you would need to do yourself in your JFrame otherwise.

I'm trying to call Applet.class which will run numerous other classes once it's been correctly called.

The .jar is included in the build, libraries, and all that by the way.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What you posted does not look like a functional applet - it doesn't have operational start, stop and init methods, nor a constructor. Where does that code come from, and what does it have to do with the problem at hand?
Anthony Schmitt
Ranch Hand

Joined: Nov 17, 2009
Posts: 37
I think I see what I'm doing wrong. Applet.class has methods. Just because I'm making an instance of the class doesn't mean I'm callng the methods.

So, adding init(); and start(); to JInternal Frame, I get a NullPointerException here:

Anthony Schmitt
Ranch Hand

Joined: Nov 17, 2009
Posts: 37
OK, OK! So posting all of this has gotten me thinking. (I'm pretty new to this, can you tell?) I have a JTA jar and a JTA developer's JAR, and looking at Applet.java it's VERY different than Applet.class! Perhaps I need to include the developer jar in my libraries and build and call this instead?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Anthony Schmitt wrote:Perhaps I need to include the developer jar in my libraries and build and call this instead?


Yup. That's what the jar is for. Just put it in your application's classpath and use its classes as you see fit.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I still recommend you look at the link I posted. Even if you end up not using that class, it will give you an idea of how to embed an applet in an application (like, from where and when to call the applet lifecycle methods).
Anthony Schmitt
Ranch Hand

Joined: Nov 17, 2009
Posts: 37
So I include BOTH the basic JTA and JTA-SOURCE Jars in my build?

I took out JTA and replaced it with the source jar, now import can't find de.mud.jta.*;
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Anthony Schmitt wrote:So I include BOTH the basic JTA and JTA-SOURCE Jars in my build?


My guess, based solely on the names of the jars, is that JTA-SOURCE contains the source code and that JTA contains the compiled classes.

I took out JTA and replaced it with the source jar, now import can't find de.mud.jta.*;


Which confirms my guess.
Anthony Schmitt
Ranch Hand

Joined: Nov 17, 2009
Posts: 37
You are correct, Paul.

Sadly, I'm still not any closer to getting the applet to run in my JInternalFrame.
Anthony Schmitt
Ranch Hand

Joined: Nov 17, 2009
Posts: 37
I think this is failing because it's trying to get info from a config file... this is where I get the nullpointer:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to run applet in JEditor
 
Similar Threads
Problem in Opening JPopupMenu
Menu applet refresh problem - please help
haveing trouble with applet animation plz help
JMenuBar on the move
tree in frame, frame in applet