Note that there are some explanatory texts on larger screens.

plurals
  1. POJava applet doesn't draw or accept mouse inputs in browser, but does in Eclipse Appletviewer
    text
    copied!<p>I'm doing a personal project called "Electromagnetic Field Hockey" (named after Electric Field Hockey on <a href="http://phet.colorado.edu" rel="nofollow">The University of Colorado's PhET website</a>). I've decided to port the application to a java applet on my website.</p> <p>The problem is that the applet will not accept any mouse input, and I don't even know if it started because the graphics disappear when I switch tabs and back. I know the applet is finding the code and codebase because the applet initializes and renders the first frame of the graphics correctly, then does nothing. What's peculiar is the applet works fine in Eclipse's Appletviewer. I suspect that the culprit is the start() method, which I think somehow isn't being executed in a browser.</p> <p>In case it helps, you can find the applet at <a href="http://leo.scruffohio.net/programs/EMFieldHockey.html" rel="nofollow">http://leo.scruffohio.net/programs/EMFieldHockey.html</a>. I tested it with Firefox on Linux and Safari on a Mac so it's not a system-dependent issue. Note that the application works when you run the jar file (located at <a href="http://leo.scruffohio.net/programs/java/thebombzen-emhockey-dev3.jar" rel="nofollow">http://leo.scruffohio.net/programs/java/thebombzen-emhockey-dev3.jar</a>).</p> <p>My applet code is very simple:</p> <pre><code>public class EMFieldHockeyApplet extends JApplet { private static final long serialVersionUID = 8145754973708683690L; @Override public void init() { this.setBackground(Color.WHITE); this.setLayout(new GridLayout()); this.add(ElectromagneticFieldHockey.getInstance()); // that's the main application JPanel } @Override public void start() { ElectromagneticFieldHockey.start(); } @Override public void stop(){ ElectromagneticFieldHockey.stop(); } } </code></pre>
 

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