• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem when running with browser, fine when run with "java colorswitch.ColorSwitch"

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am new to java are have a problem with a swing app. When I run "java colorswitch.ColorSwitch" it works, but when I use the below html snipper it gives this error....
java.lang.ClassCastException: colorswitch.ColorSwitch
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source).....

I am using Forte and it also runs fine if I run the .class file direcly in Forte.
Any help would be greatly appreicated.
====================================================
HTML CODE
........
<PARAM NAME = CODE VALUE = "colorswitch.ColorSwitch" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<PARAM NAME="scriptable" VALUE="false">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.3" CODE = "colorswitch.ColorSwitch" WIDTH = 150 HEIGHT = 150 scriptable=false......<br /> ......
=====================================================
 
Peter Knight
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm the HTML code didn't show up... I guess cause HTML is on (don't know how to turn it off but maybe this will work)....
==============================
HTML CODE..
.PARAM NAME = CODE VALUE = "colorswitch.ColorSwitch" >
.PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
.PARAM NAME="scriptable" VALUE="false">
.COMMENT>
.EMBED type="application/x-java-applet;version=1.3" CODE = "colorswitch.ColorSwitch" WIDTH = 150 HEIGHT = 150 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED></COMMENT>;
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you possibly provide a little more info? Does your ColorSwitch class extend Applet? This could cause a problem.
 
timothy zimmerman
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be clearer what I meant was that if your ColorSwitch class should extend Applet, if it does not may be a problem. I didn't see any of your HTML what does the < APPLET> tag look like.
[This message has been edited by Cindy Glass (edited September 25, 2001).]
 
Peter Knight
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hopefully better explained this time.....
I am new to java are have a problem with a Swing app. When I run "java colorswitch.ColorSwitch" it works, but when I run it from a browser (with the below html code) it gives this error....
java.lang.ClassCastException: colorswitch.ColorSwitch
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source).....
I am using Forte and it also runs fine if I run the .class file directly in Forte. I have also included the Java code (but I think the java is just fine as it works when I run it directly)
Any help would be greatly appreicated. Thanks in advance....
PS: To get the HTML code I used the Java "Converter"
PPS: Hopefully the code comes out this time... If not, I noticed you can see the code if you edit the message.
====================================================
HTML CODE:

=================================================
=================================================
Java Code


[This message has been edited by Cindy Glass (edited September 25, 2001).]
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your class runs fine as a stand alone program because it is a stand alone program and it doesn't run fine as an applet, because it is not and applet. Giving it a main() method give the VM something to start up when it's run as a program. Applets follow different rules. First, at least one of the classes involved must extend Applet or JApplet (the swing version and more relavent in this case). Main() is never called for applets though. They have different methods you can override based on their life-cycle: init(), start(), paint() - used more with Applet than JApplet, stop(), and destroy(). Programs are often written to function as both application and applet, but you'll have to provide both sets of requirements. I recommend bouncing over to Sun's Java Tutorial and reading up on applets, then see if you can modify your code to work under both paradimes. It's not too tough. Good luck!
 
Peter Knight
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay..... great, thanks for your help. I will check out the differences between a applet and an application.
Thanks again.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic