Re: GUI question
jason wrote:
GUI1 - i have approximately 10 components. all working as they should.
I have to echo Lew's advice here. You have one GUI. You have many GUI
components. Some of those components are Components, JComponents,
Windows, etc. But still only one GUI.
Off the top of my head, it sounds like you are trying to add a second
Window to the existing user interface. But I'm not really sure, because
you explain it oddly.
Your terminology makes it difficult to understand you. You say you've
only used GUI components from a client perspective, which I can believe.
Please try to learn a little from this post and use a more standard
(and precise) terminology. You sound like you are not a native English
speaker; is that true?
when i use my actionlistener on my button, i expect my progressbar in
GUI1 to update accordingly as updated by a component update call (ie:
component(11).setValue(i)). unforunately it is not doing so.
As Eric just said, and we all said previously, that is because you have
locked up the EDT (the only means by which the GUI can update) and
prevent it from running.
Please refer to this page again.
<http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html>
Especially this part:
<http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html#bars>
and the source code for that example. It does this:
<http://java.sun.com/docs/books/tutorial/uiswing/examples/components/ProgressBarDemoProject/src/components/ProgressBarDemo.java>
public void actionPerformed(ActionEvent evt) {
startButton.setEnabled(false);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
//Instances of javax.swing.SwingWorker are not reusuable, so
//we create new instances as needed.
task = new Task();
task.addPropertyChangeListener(this);
task.execute();
}
where Task is a SwingWorker, which is just the easiest way of executing
code on a thread other than the EDT. Please review that code for how to
write a SwingWorker (the Task class declaration is right there with the
code).