Mega Code Archive

 
Categories / Java Tutorial / Swing
 

AbstractButton

AbstractButton       |       +--JButton, JMenuItem, JToggleButton If a button is clicked multiple times within this time period, no additional action events will be triggered. By default, the value is zero. import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JFrame; public class MultiClickThreshholdDemo {   public static void main(String[] a) {     JFrame frame = new JFrame();     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     AbstractButton bn = new JButton();     bn.setMultiClickThreshhold(1000);           bn.addActionListener(new ActionListener(){       public void actionPerformed(ActionEvent e) {         System.out.println("action");      }      });     frame.add(bn);     frame.setSize(300, 200);     frame.setVisible(true);   } }