• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Displaying Java applet in browser via HTML  RSS feed

Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good afternoon everyone. I'm new to Java and currently in a class where I need to display (and test) my applet in a web browser using HTML code. I'm able to get the string of the test program to display on the browser, but not the actual window. I've placed the HTML inside a .html file in the same folder under the same class name as the program I'm trying to view, but am having no luck. The program compiles and displays the window when run through command prompt, but does not display in the browser. If anyone can point me in the right direction, I would greatly appreciate it! I've used my search engine tirelessly without luck.

Here is the HTML code I'm using (the string displays, but window does not):

Here is the program (I have a much longer program I'm trying to run, but decided to test a smaller one for debugging) -  and thank you in advance!:

Posts: 64493
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Don't try strange colours of code like that; some people can only read certain colours.
What Applet? You are trying to extend JDialog, not JApplet. Why are you trying to use applets at all? They are obsolete. What sort of course have you got on?
You can run an applet via an html file which you open with the appletviewer tool, but youi don't have an applet. You will have to give it a main method. You will find more about it in the Java™ Tutorials.

Don't use System.exit. It might work in a single‑threaded environment, but you are here multi‑threading, so it can damage the integrity of anything used by other code. Don't catch IllegalArgumentExceptions; you cannot correct the error in code still running.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!