*
The moose likes Applets and the fly likes Convert Swing class to Applet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Convert Swing class to Applet?" Watch "Convert Swing class to Applet?" New topic
Author

Convert Swing class to Applet?

Kriss Reddy
Ranch Hand

Joined: Mar 29, 2005
Posts: 54
Hello,

I am not sure if 'Subject' is correct to this post, if not, sorry for the confusion.

I am new to applets, Swing, AWT.
To start with I took an example and changed as shown below, which works fine if main() is un-commented.


Below listed class is used in the above class.


Both classes are working fine.

Now I tried to convert them into an Applet as shown below:


Applet is called on my webpage as shown below:



Applet is loaded on my webpage, but none of the functionality is available for use, ie nothing happens when buttons are clicked. Please tell me where I went wrong.

Thanks,
Kriss.
Girish Limaye
Greenhorn

Joined: Jan 14, 2010
Posts: 1
Implement the listener interfaces. It might work properly.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41045
    
  43
So every time you click that button a new applet is created? I would not expect that to work at all, especially as it happens after the page has initially been created. Make the applet a proper part of the page from the beginning, and then call its public methods from JavaScript as necessary; search the FAQ for "LiveConnect" for more information.


Ping & DNS - my free Android networking tools app
Kriss Reddy
Ranch Hand

Joined: Mar 29, 2005
Posts: 54
Hi Girish,
Could you please tell me what those listener interfaces are?

Hi Ulf,
Make the applet a proper part of the page from the beginning

Does that mean, placing applet on the page instead of calling from javascript, as shown below?

I placed the applet on the page, applet is loaded properly but none of the buttons worked.

Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41045
    
  43
Yes, that's what I meant.
I placed the applet on the page, applet is loaded properly but none of the buttons worked.

Have you considered investigating why that is, instead of trying to running the applet in a much more convoluted way?
 
 
subject: Convert Swing class to Applet?
 
Similar Threads
Need help with Mini Telephone Directoy program please
How do I pass a frame into another class?
list of component not displayed
JScrollPane within JTable cell issue