*
The moose likes Applets and the fly likes Trouble executing(actionlistener) the swing applet properly in html Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Trouble executing(actionlistener) the swing applet properly in html" Watch "Trouble executing(actionlistener) the swing applet properly in html" New topic
Author

Trouble executing(actionlistener) the swing applet properly in html

aybee ryu
Greenhorn

Joined: Jul 19, 2011
Posts: 6

Hi,

Following is the applet code below:







then the html file looks like this:





when i run the program via eclipse as an applet it runs fine, but when i put it in the html file, the init() seems to show up but the actionlistener on the button never seems to work

Any help would be really appreciated. Thanks!!

ps: will be happy to share any additional details if required
aybee ryu
Greenhorn

Joined: Jul 19, 2011
Posts: 6
nobody has an answer for this?? That is discouraging
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
Well, you're not exactly making it easy for us to help you. For example, what's with all the empty lines? It seems you could remove about a third of your code that does nothing but impact people's ability to comprehend it.

Also, what is "the button"? A particular one? If so, which one? What happened when you did click on it? Did the handler get called? You're implying no. I suspect yes, but it just didn't do what you thought it should be doing.

Furthermore, at a quick glance, I see two catch blocks that do precisely nothing. Unless you're generating an error message of some kind that you're guaranteed to see, that's just a recipe for trouble.


Ping & DNS - my free Android networking tools app
aybee ryu
Greenhorn

Joined: Jul 19, 2011
Posts: 6
Ulf Dittmer wrote:Well, you're not exactly making it easy for us to help you. For example, what's with all the empty lines? It seems you could remove about a third of your code that does nothing but impact people's ability to comprehend it.

Also, what is "the button"? A particular one? If so, which one? What happened when you did click on it? Did the handler get called? You're implying no. I suspect yes, but it just didn't do what you thought it should be doing.

Furthermore, at a quick glance, I see two catch blocks that do precisely nothing. Unless you're generating an error message of some kind that you're guaranteed to see, that's just a recipe for trouble.





I just thought i might be messing up the way i set up my jar file with the applet or something similar, so providing more stuff would be redundant..... Please do note that the applet works absolutely fine when I run it off eclipse as an applet. The problem is when i put it up on the html....i have tried multiple browsers(just to make the compatible between different browsers thing)


Let's go over the whole project in detail.....


the primary objective of this project to find a list of small embedded servers in a local network.

files:

ui.java----->primary display of interface
FindSiteplayer.java---->the real part which finds these servers


ui.java








Important notes: The way I do it is initially the user sees self ip and hostname and he or she provided with a search button...as soon as the button is pressed a search in the current user subnet is initiated and the result is got back in 2d string array. this 2d array with other external data like (image icons and all) is used to dynamically create a panel which is set right below the search button. Again the whole thing works absolutely the way it is suppose to be in an applet form in the IDE but as soon as i import the project as a jar file from the eclipse IDE and try embedding it in a html page....only the initial state is reached (the hostaddress & name with search button) any later panels created after actionlistener doesn't show up on the page and one gets a feeling that the search button actually does nothing. Also do note the way i make jar file in eclipse:- file->export->JAR file->(select everything in the resources to export)+check export generated class files and res +check export java source files and res +<options> check compress the contents of the jar file




please let know if you need any further info or clarification + anything you would want me try out (i m following this thread hardcore, so any response can be dealt with almost immediately)

Thanks

Greatly appreciate it




aybee ryu
Greenhorn

Joined: Jul 19, 2011
Posts: 6
Please also note that there might be a lot of dead code, reason being it went through many iterations and this is a very pre-alpha state project.

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
You misunderstood: I was asking for much less code, not more code. The more code you post, the less likely it is that anyone will bother to go through it.
aybee ryu
Greenhorn

Joined: Jul 19, 2011
Posts: 6
Ulf Dittmer wrote:You misunderstood: I was asking for much less code, not more code. The more code you post, the less likely it is that anyone will bother to go through it.




I just got it there if someone actually wanted to dig deeper, i guess just the important note section is good enough from the previous post then.


Important notes: The way I do it is initially the user sees self ip and hostname and he or she provided with a search button...as soon as the button is pressed a search in the current user subnet is initiated and the result is got back in 2d string array. this 2d array with other external data like (image icons and all) is used to dynamically create a panel which is set right below the search button. Again the whole thing works absolutely the way it is suppose to be in an applet form in the IDE but as soon as i import the project as a jar file from the eclipse IDE and try embedding it in a html page....only the initial state is reached (the hostaddress & name with search button) any later panels created after actionlistener doesn't show up on the page and one gets a feeling that the search button actually does nothing. Also do note the way i make jar file in eclipse:- file->export->JAR file->(select everything in the resources to export)+check export generated class files and res +check export java source files and res +<options> check compress the contents of the jar file
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
I advise again to properly handle exceptions - running an applet in a browser is NOT the same as running it in appletviewer or an IDE. Things that work in one of those environments don't necessarily work in the others.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble executing(actionlistener) the swing applet properly in html
 
Similar Threads
empty Jframe
ActonListener
applet cannot start error in browser ...
What is the best way to create GUI components- in-line, methods, inner classes or separate classes
drawRect()