Forums Register Login

Trouble executing(actionlistener) the swing applet properly in html

+Pie Number of slices to send: Send

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
+Pie Number of slices to send: Send
nobody has an answer for this?? That is discouraging
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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:)




+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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

 
+Pie Number of slices to send: Send
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.
Pay attention! Tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1372 times.
Similar Threads
applet cannot start error in browser ...
What is the best way to create GUI components- in-line, methods, inner classes or separate classes
drawRect()
ActonListener
empty Jframe
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 21:49:49.