Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>UPDATE</strong>:<br> Based on your feedback, it seems you are trying to achieve the following:<br> Use the code of an existing Applet (<strong><a href="http://ippex.pppl.gov/tokamak/tokamak.htm" rel="nofollow">found here</a></strong>) in a Desktop application (i.e. in a JFrame).</p> <hr> <p>Converting an Applet to a Desktop application is an "undertakable" task, the complexity of which depends on how much "Applet-specific" stuff is used by the Applet. It can be as simple as creating a JFrame and adding <code>myFrame.setContentPane(new myApplet().getContentPane());</code> or as complex as...hell.<br> <strong><a href="http://www.dreamincode.net/forums/topic/28410-application-to-japplet-and-reverse/" rel="nofollow">This tutorial</a></strong> might be a good place to start.</p> <hr> <p>After taking a look at the Applet at hand, it seems to be fairly easy to convert it. The only complicating factor is the use <code>Applet</code>'s methods <code>getCodeBase()</code> and <code>getImage(URL)</code> (somewhere in the code). These two methods result in a <code>NullPointerException</code> if the Applet is not deployed as...an Applet.</p> <p>So, what you can do is override those two methods in order to return the intended values (without the exception). The code could look like this:</p> <pre><code>/* Import the necessary Applet entry-point */ import ssfd.SteadyStateFusionDemo; /* Subclass SSFD to override "problematic" methods */ SteadyStateFusionDemo ssfd = new SteadyStateFusionDemo() { @Override public URL getCodeBase() { /* We don't care about the code-base any more */ return null; } @Override public Image getImage(URL codeBase, String imgPath) { /* Load and return the specified image */ return Toolkit.getDefaultToolkit().getImage( this.getClass().getResource("/" + imgPath)); } }; ssfd.init(); /* Create a JFrame and set the Applet as its ContentPane */ JFrame frame = new JFrame(); frame.setContentPane(ssfd); /* Configure and show the JFrame */ ... </code></pre> <p>The complete code for an example JFrame Class can be found <strong><a href="http://ideone.com/WCX3JI" rel="nofollow">here</a></strong>.</p> <hr> <p>Of course, you need to have all Classes from the original Applet accessible to your new Class (e.g. put the original Applet in your classpath).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload