Solved

How to create a responsive GUI in Java Swing?

Posted on 2004-09-15
9
1,170 Views
Last Modified: 2011-09-20
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...
:)
0
Comment
Question by:sarulprakash
  • 5
  • 3
9 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12064792
0
 
LVL 37

Accepted Solution

by:
zzynx earned 50 total points
ID: 12064799
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
 
LVL 6

Expert Comment

by:expertmb
ID: 12064909
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Author Comment

by:sarulprakash
ID: 12065430
thank you zzynx for the information.

- Arul :)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12065891
Thanks for accepting.

PS. For my interest: what kind of answer would you have given an A-grade?
0
 
LVL 1

Author Comment

by:sarulprakash
ID: 12072372
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
 
LVL 37

Expert Comment

by:zzynx
ID: 12072596
>>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
 
LVL 1

Author Comment

by:sarulprakash
ID: 12075267
how do we split points. This is my first posting in this forum. : (

Arul.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12075383
>>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

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question