How to call applet in gwt

979 views
Skip to first unread message

ship

unread,
Sep 30, 2008, 3:37:44 AM9/30/08
to Google Web Toolkit
hi all,
I am using gwt in a application in which when i click on a button,
then an applet will be called.
How can i call a simple java applet in my gwt app???
Pl help me!!!!!!!!!

Martin Trummer

unread,
Sep 30, 2008, 5:51:20 AM9/30/08
to Google Web Toolkit
AFAIK, gwt does not directly support this.
however, this lib looks very promising: http://code.google.com/p/gwtai/
note: I haven't used it yet
If you do, please let us know if it works for you.

Lothar Kimmeringer

unread,
Sep 30, 2008, 5:59:47 AM9/30/08
to Google-We...@googlegroups.com
Hello ... whoever,

ship schrieb:

first of all, your keyboard needs a repair, it repeats ! and ?
all the time.

What exactly do you mean with "call an applet"? If we're
talking of just starting an applet, you can create a
HTML-widget and set the HTML-tags for the applet (directly
typed in, might not work):

HTML applet = new HTML();
panel.add(applet);
applet.setHTML("<APPLET src=\"/applets/MyApplet.class\" etc.");

The browser happily interprets the HTML and should load and
start the applet. That way you should also be able to pass
arguments using the PARAM-tags.

If you want a steady communication, you have to use the Java-
to-Javascript-bridge provided by the browser, that you have
to access using JSNI.


Regards, Lothar

Martin Trummer

unread,
Oct 1, 2008, 7:00:11 AM10/1/08
to Google Web Toolkit
> HTML applet = new HTML();
> panel.add(applet);
> applet.setHTML("<APPLET src=\"/applets/MyApplet.class\" etc.");

Yes, but in this case you have to take care that it works in different
browsers, which can become a nightmare:
http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html#anywhere

Lothar Kimmeringer

unread,
Oct 1, 2008, 7:06:39 AM10/1/08
to Google-We...@googlegroups.com
Martin Trummer schrieb:

>> HTML applet = new HTML();
>> panel.add(applet);
>> applet.setHTML("<APPLET src=\"/applets/MyApplet.class\" etc.");
>
> Yes, but in this case you have to take care that it works in different
> browsers, which can become a nightmare:

I know that and I assumed that the one asking is aware of that
as well. There are established solutions for this (nested
OBJECT-APPLET-tags, etc.) or you take advantage of the fact that
GWT creates one HTML-file per browser and create the fitting
HTML for every specific browser (using the replace-with-directive
in the GWT.xml-file).

Anyway. Because I don't know if I'm right what "ship" means with
"call an applet" I wasn't going into much detail about this.


Regards, Lothar

ship

unread,
Oct 6, 2008, 2:22:07 AM10/6/08
to Google Web Toolkit
hi, Lothar sir
As you wrote i had tried. But a error is occured that class can not
found.
I had write these lines:
HTML applet = new HTML();
panel.add(applet);
applet.setHTML("<APPLET code=\"JFileChoose.class\"></applet>");
I put my class file in classes folder of web.
I want browse a folder so i write a applet by using JFileChooser. Now
i want to run this applet on clicking a button. I had tried but after
clicking on button applet is not run.
Pl help.

ship

unread,
Oct 6, 2008, 4:55:41 AM10/6/08
to Google Web Toolkit

Lothar Kimmeringer

unread,
Oct 6, 2008, 7:29:11 AM10/6/08
to Google-We...@googlegroups.com
Hello,

ship schrieb:


> As you wrote i had tried. But a error is occured that class can not
> found.
> I had write these lines:
> HTML applet = new HTML();
> panel.add(applet);
> applet.setHTML("<APPLET code=\"JFileChoose.class\"></applet>");
> I put my class file in classes folder of web.
> I want browse a folder so i write a applet by using JFileChooser. Now
> i want to run this applet on clicking a button. I had tried but after
> clicking on button applet is not run.

Create a HTML-page and try it out directly. Most likely the
HTML-code you used is not supported by the browser you used
for testing (as far as I know IE expects the OBJECT-tag instead
of the APPLET-tag, which is used by Mozilla-browsers).

BTW: As long as you don't have signed the applet, the JFileChooser
will not work.


Regards, Lothar

Reply all
Reply to author
Forward
0 new messages