The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

If that's the case

Posted by Hiran on January 30, 2002 at 5:17 PM

Micah, if this is the reason:


And so when you set the text to "Working..." and then go on to perform the calculation no screen update is performed until you leave that method. The reason working is displayed when you enter a non numerical value is that "Working" is set in the text display and then an exception cause an exit from the action performed method. Now when update is called the text field is redrawn with working.

then would it work if the setText method was called from another method. For example, could David create a method (let's call it showWorking for argument's sake) inside the (outer) public class, and have the inner class call showWorking before it starts the calculation. If not, what about using the append method of JTextField?
Hiran

> Actually the reason it does not work is that you are in running in one thread and while you are in action perform the gui will not perform an update on the screen. And so when you set the text to "Working..." and then go on to perform the calculation no screen update is performed until you leave that method. The reason working is displayed when you enter a non numerical value is that "Working" is set in the text display and then an exception cause an exit from the action performed method. Now when update is called the text field is redrawn with working.

> I'm not to familiar with GUI but you need to force a repaint or update after setText field is called. Other wise it is set to "Working" then to the result before the screen is updated.

> > Hi
> > Your applet works as fine. If you enter a small number then the time taken between the display of "Working..." and the actual result is so small that you cannot see the text "Working...". But it is displayed. If you enter a big number and then hit enter then text "Working...." is displayed. If you enter a text , say "abc", which is not a number then also it displays "Working..." for ever because Interger.parseInt() throws exception.

> > Thanks
> > Kishori





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us