problem with JTabbedPane and stateChangeEvent and set busy cursor



Hi,
I have written an application that consists of several JTabbedPanes
(the number depends on the users action) and each Pane will contain a
number of JInternalFrames showing some graphs. The Graphs are drawn
with help of the paintComponent(Graphics g) function and are for the
first time rather time consuming so I'd like to implement a set busy
cursor function which is aactivated as soon as a user presses a tab and
which is deactivated as soon as the drawing is done and the selected
tabbedpane is fully visible.

So I added a change listener:

tpane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent evt) {
JTabbedPane pane = (JTabbedPane)evt.getSource();
// Get current tab
int sel = pane.getSelectedIndex();
io.log( " maingui$1.stateChanged: tab = "+sel );
}
});

I can now see that the program issues several stateChanged events once
the user clicks on a tab. It looks like that as many events are issued
as there are tabs. E.g. if I have 4 tabs I will get the following
output:

maingui$1.stateChanged: tab = 1
maingui$1.stateChanged: tab = 1
maingui$1.stateChanged: tab = 1
maingui$1.stateChanged: tab = 1

However they don't seem to come exact at beginning or at the end.

Is there another possibility that I could use?

.


Quantcast