2017年5月18日 星期四

Java Swing

addActionListener() means the class is listenable to some actions.
The listenable classes includes
Swing: JComboBox, Jbutton, JTextField, JMenuItem, JCheckBox, JRadioButton
SwingX: JXDatePicker,

It is common to make a class extends from a listenable Swing class and implements ActionListener for actionPerformed(ActionEvent).

Classes that implements ActionListener becomes a listener that listens to some listenable classes.
When some actions happens to listenable classes, actionPerformed(ActionEvent) will be invoked.
When actionPerformed, ActionListener reacts to the action.
It is like action and reaction pair that Listenable and ActionListener comes together always.

Some common methods of ActionEvent are:
Object EventObject.getSource()
String getActionCommand() like button name
long getWhen()

沒有留言:

張貼留言

2007 to 2023 HP and Dell Servers Comparison

  HP Gen5 to Gen11  using ChatGPT HP ProLiant Gen Active Years CPU Socket Popular HP CPUs Cores Base Clock Max RAM Capacity Comparable Dell ...