// When you click an event, the event will be monitored at any time, even if the button is no longer available;
// General event. The setting button will not be available after it is unavailable
The following is an example:
package eeeee;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.SwingUtilities;import javax.swing.UIManager;import org.dyno.visual.swing.layouts.Constraints;import org.dyno.visual.swing.layouts.GroupLayout;import org.dyno.visual.swing.layouts.Leading;//VS4E -- DO NOT REMOVE THIS LINE!public class bbbb extends JFrame {private static final long serialVersionUID = 1L;private JButton jButton0;private JButton jButton1;private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";public bbbb() {initComponents();}private void initComponents() {setLayout(new GroupLayout());add(getJButton0(), new Constraints(new Leading(52, 10, 10), new Leading(39, 10, 10)));add(getJButton1(), new Constraints(new Leading(195, 10, 10), new Leading(39, 12, 12)));setSize(320, 240);}private JButton getJButton1() {if (jButton1 == null) {jButton1 = new JButton();jButton1.setText("jButton1");jButton1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent event) {jButton1ActionActionPerformed(event);}});}return jButton1;}private JButton getJButton0() {if (jButton0 == null) {jButton0 = new JButton();jButton0.setText("jButton0");jButton0.addMouseListener(new MouseAdapter() {public void mouseClicked(MouseEvent event) {jButton0MouseMouseClicked(event);}});}return jButton0;}private static void installLnF() {try {String lnfClassname = PREFERRED_LOOK_AND_FEEL;if (lnfClassname == null)lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();UIManager.setLookAndFeel(lnfClassname);} catch (Exception e) {System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL+ " on this platform:" + e.getMessage());}}/** * Main entry of the class. * Note: This class is only created so that you can easily preview the result at runtime. * It is not expected to be managed by the designer. * You can modify it as you like. */public static void main(String[] args) {installLnF();SwingUtilities.invokeLater(new Runnable() {@Overridepublic void run() {bbbb frame = new bbbb();frame.setDefaultCloseOperation(bbbb.EXIT_ON_CLOSE);frame.setTitle("bbbb");frame.getContentPane().setPreferredSize(frame.getSize());frame.pack();frame.setLocationRelativeTo(null);frame.setVisible(true);}});}//00private void jButton0MouseMouseClicked(MouseEvent event) {jButton0.setEnabled(false);System.out.println("click 00");}//11private void jButton1ActionActionPerformed(ActionEvent event) {jButton1.setEnabled(false);System.out.println("click 1111");}}
After you click button0, it is set to unavailable, but it still responds to the event (the printed output in it)
After you click "button1", you can set it to unavailable and click "it". This means it is unavailable.
From here we can intuitively see the differences between the two events. I will not talk about the deeper truth, hey