How to create a responsive GUI in Java Swing?

Hi all,

I am new to JAVA Development and I am developing an application that reads a content of a folder and the XML files and parse the files and transform them into html.

Every thing seems to work fine. I use JFileChooser. and get the directory as input. I also have kept a label in to show the status. For getting th efiles in the directory I use a method. For parsin gI use another method and for transforming I use another method. All the methods are in different classes. When I click the accept button. the status bar need to change to "Processing the input" then when it is parsing the XML files it needs to show "Parsing..." and when transforming it needs to show "Transforming"... I have used the JLabels setText() options but it is not happening. the JLabel is not updating its value.

Any Idea on this...

Thanks and regards,
Arul...
:)
LVL 1
sarulprakashAsked:
Who is Participating?
 
zzynxConnect With a Mentor Software engineerCommented:
The purpose of SwingWorker is to implement a background thread that you can use to perform time-consuming operations
without affecting the performance of your program's GUI
0
 
zzynxSoftware engineerCommented:
0
 
expertmbCommented:
the events related to ui controls are run within a single thread edt(event dispatch thread). when the accept button is clicked the, till the event completes the other gui events or repaints are held, no other events will be executed. thats the reason setting the label with different texts is not happening.

use swing worker thread as suggested by zzynx.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
sarulprakashAuthor Commented:
thank you zzynx for the information.

- Arul :)
0
 
zzynxSoftware engineerCommented:
Thanks for accepting.

PS. For my interest: what kind of answer would you have given an A-grade?
0
 
sarulprakashAuthor Commented:
Hi zzynx,

If you have provided the comment like whats is wrong with my current practice, novice like me will be able to understand better.Example is what expertmb has given. I would have given A for that. Sorry if I am wrong about making this kind of decision.

Your link solved the problem for me thats for sure. and thanks a lot for that.

Arul....
0
 
zzynxSoftware engineerCommented:
>>If you have provided the comment like whats is wrong with my current practice,
>>novice like me will be able to understand better
I see.

>>Sorry if I am wrong about making this kind of decision.
Nothing wrong with that. You decide. Just to know for myself for future comments.

>>Example is what expertmb has given.
Then I wonder why you didn't split the points.

>>Your link solved the problem for me thats for sure. and thanks a lot for that.
You're welcome.
0
 
sarulprakashAuthor Commented:
how do we split points. This is my first posting in this forum. : (

Arul.
0
 
zzynxSoftware engineerCommented:
>>This is my first posting in this forum
Then browsing through the help files is a certainly a good idea ;°)

>>how do we split points
Read the item "Can I split the points" at
http://www.experts-exchange.com/Programming/Programming_Languages/Java/help.jsp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.