Re: Getting java.lang.IllegalStateException: This must happen in the event thread!, when disabling an action

Emilian Bold <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <CAL6R17BU4zZ8Zn9+mOZ4v-mk0fehkwzuxLeGrDfLR0531ef_hw@mail.gmail.com>
Because you are not doing that in the event thread. See
https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html

Try putting that in an EventQueue.invokeLater.


--emi

On Thu, Oct 27, 2016 at 4:14 PM, kmilito <[email protected]> wrote:

> I am trying to disable an action outside actionPerformed(ActionEvent e) by
> using action.setEnabled(false), but I get the following error:
>
>
> Code:
> java.lang.IllegalStateException: This must happen in the event thread!
>     at org.openide.awt.Actions$Bridge.propertyChange(Actions.java:929)
>     at org.openide.util.WeakListenerImpl$PropertyChange.propertyChange(
> WeakListenerImpl.java:197)
>     at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:
> 335)
>     at java.beans.PropertyChangeSupport.firePropertyChange(
> PropertyChangeSupport.java:327)
>     at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(
> SwingPropertyChangeSupport.java:92)
>     at java.beans.PropertyChangeSupport.firePropertyChange(
> PropertyChangeSupport.java:263)
>     at javax.swing.AbstractAction.firePropertyChange(
> AbstractAction.java:276)
>     at javax.swing.AbstractAction.setEnabled(AbstractAction.java:236)
>
>
>
> Any ideas what I am getting this error?
>
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.