Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Thread Safety - JFrames and UIs

843785Jul 14 2008 — edited Jul 17 2008
If I understand it correctly, the guidling principle to 'thread safety' is to separate the classes for user interfaces and the logic behind the interfaces.

So, what I've been doing is to set up pairs of classes; one for the user interface (JFrame, JPanel, JTextBox, layout etc) and another 'checker' class (with regexes, logic etc) to interpret the inputs into the UI and to pass them back to the 'engine' code classes. For instance, the user might input the string '2000' into a JTextBox and the checker class will interpret this as a date with a value of 01/01/2000 00:00:00.000 and pass it on. The checker class will also check that a finish date occurs after a start date, and so on.

Question 1: does it matter which way round I call the classes? Should the UI class call the checker class, should it be the other way round or does it make no difference (other than following up my own conventions)?

Question 2: can you briefly explain what 'thread safety' means anyway?

Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 14 2008
Added on Jul 14 2008
7 comments
214 views