Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

EDT and SwingUtilities.invokeLater help

Thread view: 
pek - 22 Oct 2007 22:51 GMT
OK, I got really confused about when to use SwingUtilities or not.
For example.

Let's say that I have a simple class that extends JFrame, a private
JButton field testButton and a private JLabel field testLabel.

Somewhere down the code I right the following:

testButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
testLabel.setText("testButton");
}
});

Does this needs to be converted to :

public void actionPerformed(ActionEvent e){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
testLabel.setText("testButton");
}
})
});

or not? And why..?
When exactly do I need to use SwingUtilities?
If I have a thread that changes a JLabel inside/outside the class, do
I need it?
If the thread instead of changing the testLabel invokes
testButton.doClick(), will I still need to use SwingUtilities..?

Overall, is there any good reference in the internet to explain all
these..?

Thank you very very very very much for your help..
RedGrittyBrick - 22 Oct 2007 23:50 GMT
> OK, I got really confused about when to use SwingUtilities or not.
<snippage>
> Overall, is there any good reference in the internet to explain all
> these..?

http://mindprod.com/jgloss/thread.html#SWINGTHREADS
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html
pek - 23 Oct 2007 00:30 GMT
On Oct 23, 1:50 am, RedGrittyBrick <RedGrittyBr...@SpamWeary.foo>
wrote:
> > OK, I got really confused about when to use SwingUtilities or not.
> <snippage>
> > Overall, is there any good reference in the internet to explain all
> > these..?
>
> http://mindprod.com/jgloss/thread.html#SWINGTHREADShttp://java.sun.com/docs/book
s/tutorial/uiswing/concurrency/index.html

Thank you very much. ;)
Daniel Pitts - 23 Oct 2007 04:42 GMT
> On Oct 23, 1:50 am, RedGrittyBrick <RedGrittyBr...@SpamWeary.foo>
> wrote:
[quoted text clipped - 7 lines]
>
> Thank you very much. ;)

Also, there is a good book about the subject. In my opinion, well
worth the price. Its called Java Concurrency In Practice.  You can
read more about the book at
<http://virtualinfinity.net/wordpress/technical-book-recommendations/
java-concurrency-in-practice/>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.