File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes getApplet() throws incompatible type error ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "getApplet() throws incompatible type error ?" Watch "getApplet() throws incompatible type error ?" New topic
Author

getApplet() throws incompatible type error ?

achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
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 :-)


humanum errare est.
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
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

Joined: Jul 29, 2002
Posts: 277
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

Joined: Nov 04, 2001
Posts: 1871
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

Joined: Jul 29, 2002
Posts: 277
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

Joined: Mar 10, 2004
Posts: 7
Your ClientApplet needs to extend JApplet I think
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: getApplet() throws incompatible type error ?