Java Event Sequence

I have two events for two separate components, but there is a problem. The JTabbedPane stateChanged event event is fired before the focusFost JFormattedField event. Is there a way to make the StateChange event fire after the focusLost event.

Thanks, Tuna

+3
source share
2 answers

As long as Java guarantees that the event will be fired, the order will not be guaranteed and may vary on different platforms.

A potential solution is to wrap stateChanged code in SwingUtilities.invokeLater (). This will put the code at the end of the Thread Dispatch Thread (EDT) so that it runs after the focusLost code.

+3
source

, JTabbedPane, fireStateChanged() , , , stateChanged .

. , , (SwingUtilities2.tabbedPaneChangeFocusTo(newComp)), , , .

fireStateChanged() - , JTabbedPane , , .

, , .

+2

Source: https://habr.com/ru/post/1744003/


All Articles