• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getApplet() throws incompatible type error ?

 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I've implemented a class TXRecord which collects transient record data from client applets using a Hashtable. To achieve this, my client applets tries to get a handle on TXRecord in order to use its method to insert a record.
However the client applet is throwing a compile time error

incompatible types
found : java.applet.Applet
required: javax.swing.Applet
.......{ JApplet app_txrecord = JApplet.getAppletContext().getApplet("TXRecord");

Here is the TXRecord class which it objects to...

And here is the code snippet which tries to get a handle on TXRecord

Where have I gone wrong here, can anyone helpout please!
TIA :-)
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Achana
In the line,
JApplet app_txrecord = ...
Try to replace JApplet with Applet OR
cast the right hand side with (javax.swing.JApplet)
because getApplet() will return java.awt.Applet object and on left hand side you have app_txrecord as JApplet.
Thanks
Maulin
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Thanks for replying.
I've tried casting it as JApplet and leaving it as Applet, like this:

All of them throws the same compile time error msg;

cannot resolve symbol
method getAppletContext()
Applet app_txrecord = (Applet)getAppletContext().getApplet("TXRecord");

TIA :-)
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Achana
I see that you removed JApplet.getAppletContext() and instead just using getAppletContext() directly ...may be its just while editing you ended up removing it..
Put it back in addition to the casting you are doing and see it works...
Regards
Maulin
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for replying.
I've tried out all these combinations, they all return the same compile time error, namely "cannot resolve symbol, method getAppletContext()"

TIA :-)
 
Jason Huntz
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your ClientApplet needs to extend JApplet I think
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic