aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes About using Swing components in SCJD exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "About using Swing components in SCJD exam" Watch "About using Swing components in SCJD exam" New topic
Author

About using Swing components in SCJD exam

Helen Ma
Ranch Hand

Joined: Nov 01, 2011
Posts: 451
When I read Chatper 4 of Monkhouse book, Swing is not thread safe and it is recommended that a Swing component should be accesed by only one thread.
As far as the exam is a concern, if two threads try to write a string into a JTable cell, should I still synchronized the JTable object?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

Your Swing client is such a simple application. There is no need to have a multi-threaded approach. So it's not an issue at all.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1509
    
    5

I agree with Roel De Nijs.

Helen Ma wrote:As far as the exam is a concern, if two threads try to write a string into a JTable cell, should I still synchronized the JTable object?

Well, is it really going to happen? The chances are very high that the String will come from server as part of remote object, and your client will write that String in JTable. I don't see any reason why your client should do it in multi-threaded way.

And secondly, the moment you open another client, there will be completely new GUI, which means the JTable also would be different one.

So, there's no need to worry about thread-unsafety of swing components.

I hope this helps.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About using Swing components in SCJD exam