• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with swing GUI due to lengthy code running in background.

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I have been studying about threads, I am unable to implement event dispatching. I have read a lot in the web, but there are no bold examples available. I only understood the concept. But unable to implement it. Moreover I am unable to understand invokeLater() usage.

Lengthy programs are placed, I am unable to understand them. Please can anyone tell me how to implement this one with an example program.

I am working on an application, where I will be sending messages to mobiles from a system using a GSM modem. I want to implement this one in my application.

I have coded the entire thing, but the problem is once I hit the send message button the GUI is becoming inactive, after sending all messages it is becoming active.

Then I understood that I have to use Event Dispatching concept. Can anyone help me with small examples?

Thank you all in advance, have a great day.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SwingUtilities.invokeLater is used to make a task run in the Event Dispatching Thread. Which means that it won't block the running process. There's a simple example in the API. If you are using Java 1.6, you can also make use of the SwingWorker class to interact with your UI, without blocking the running thread. If you're not, then you can get the SwingWorker here.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Christophe, I searched the internet, I am unable to understand those examples really, and I am using java 1.6. I have seen SwingWorker class also, but before understanding the basic programs how can I understand that. Please can you give me a sample program. I know that we cannot expect code here, but I want a sample program, I will see it and learn.

Thank you in advance, have a nice day.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anyone who can help me?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DId you check out the SwingWorker link Christophe provided? It contains sample code with explanations.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Maneesh, I did not understand that. Thats what I am saying from beginning.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, after studying a lot about the stringworker class, I wrote this program seeing an example. This one.


My aim is to verify the entered password. The password is in a text file in an encrypted format(MD5). I am using a class called "Verify". There is a function in it which will take the entered password and check whether it is right or wrong. Since this may take some time, opening a file, decrypting the password and comparing it, so I decided to go with StringWorker class. I have done up to here. Now I dont know what to do.

Can anybody help me please. Thank you all in advance. Have a nice day.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anybody there!!!
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, more than two days have passed since you were pointed to SwingWorker page, so you must have read the page by now, and also the javadocs of that class. Have you run the example codes shown there? Did you understand what it's all about? If not, what -exactly- is still unclear about it?

(And no, the solution does not involve extending the SwingWorker class.)

I'd also advise not to post anything that ends in multiple exclamation marks - that's very unlikely to make people here want to help you.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dittmer, sorry for the exclamation marks, I was really tired waiting for it.

Somehow I have done this one, I don't know whether this way is correct or not, but I got the expected output. I have understood the concept, just for simulation I am doing this program.

I did not understand this one.

(And no, the solution does not involve extending the SwingWorker class.)


The new code is this


Please tell me if I have done anything wrong. Once again I am sorry. Thank you in advance.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, now I am understanding the concept, I am leaning it and able to feel it, if i get any doubts I ll return.

Thanks for the help and sorry for being rude. Have a nice day.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I was really tired waiting for it.


That was obvious, but posts here are at the discretion of our visitors - so any given question may never be answered. Becoming impatient over that really doesn't accomplish anything (besides possibly turning off people from answering). But all is good now :-)

I did not understand this one.

(And no, the solution does not involve extending the SwingWorker class.)


I see what you're doing now; in light of that, i retract that statement.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dittmer you are right, thanks for correcting me, I wont repeat this again.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody, I have a doubt, can I have to inner classes which extend SwingWorker class?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

krishna Karthikk wrote:Hi everybody, I have a doubt, can I have to inner classes which extend SwingWorker class?



It may be a good idea to start a new topic for a new question -- as this topic has been resolved.

Henry
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic