Java AbstractButton.doClick(int pressTime)
Syntax
AbstractButton.doClick(int pressTime) has the following syntax.
public void doClick(int pressTime)
Example
In the following code shows how to use AbstractButton.doClick(int pressTime) method.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
// w w w .ja v a 2 s . com
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
public class Main {
public static void main(String[] args) {
AbstractButton jb = new JButton("Press Me");
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.out.println(((JComponent) arg0.getSource())
.getFont());
}
});
jb.doClick(1000);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(jb);
f.pack();
f.setVisible(true);
}
}
Home »
Java Tutorial »
javax.swing »
Java Tutorial »
javax.swing »