Solved

How to create a responsive GUI in Java Swing?

Posted on 2004-09-15
9
1,035 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
 
LVL 1

Author Comment

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

- Arul :)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

762 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now