Actually there is a very simple way to enable and disable a button in java that uses a mouse listener.
class HoldListen extends MouseAdapter { @Override public void mousePressed(MouseEvent e) { JButton bt = (JButton)e.getSource(); if (!bt.isEnabled()) { return; }
I found your question trying to create something similar, and thatβs how I solved it. All MouseListener methods return void, so it works pretty well. In my situation, returning to an ActionListener would require a lot of extra work, while a MouseListener would be ideal for the job. Click set the variable that Release undid and another thread used the variable in the current simulation.
source share