Updating jtextarea

21 Dec

We dutifully start up a new thread so that our queries won't block the user interface: That was the easy bit.

But now, from our query thread, we want to update a progress bar or some other component showing the current progress to the user.

This update release specifies the following security baseline: In December, 2008, Java SE 1.4.2 reached its end of service life with the release of 1.4.2_19.

Future revisions of Java SE 1.4.2 (1.4.2_20 and above) include the Access Only option and are available to Java for Business subscribers.

The full internal version number for this update release is 1.5.0_22-b03 (where "b" means "build"). This release contains Olson time zone data version 2009m.

For more information, refer to Timezone Data Versions in the JRE Software .

Note that bug fixes in previous update versions are also included in the current update version.

The version numbers are given below, complete with build number.

updating jtextarea-7updating jtextarea-60updating jtextarea-68updating jtextarea-70

The code that doesn't work is as follows (and this is just a test, mind you): JText Area ta = new JText Area(); JScroll Pane sp = new JScroll Pane(ta); public void init() (Review ID: 52291) ====================================================================== Name: st C104175 Date: 03/27/2000 bash-2.02$ //e/jdk1.3/bin/java -version java version "1.3.0rc1" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T) Java Hot Spot(TM) Client VM (build 1.3.0rc1-S, mixed mode) When you append() a line to a JText Pane in a JScroll Pane, the way of scrolling depends on how you append it: a) in a Thread - no scrolling to the new text b) in a Listener - scrolling to the new text (desirable) This is inconsistent and IMHO confusing to the user, who doesn't care about threads/events and just wonders "why is this scrolling differently from that?So from any other thread— in practice, that means code that isn't called directly from an event handler— we must specifically arrange for our GUI update code, and generally only that code, to be called on the event dispatch thread.So, supposing we have a button that launches a series of database queries.How can we do this if we're no longer in the event dispatch thread?Well, the would be a JLabel or JText Field or something of that ilk— it doesn't matter terribly much.