![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
JLabel
instances to create labels.
JTextField
instances to create text fields.
JButton
instances to create new buttons.
getText
to retrieve strings from text fields.
setText
to insert strings into text fields.
parseInt
,
from the Integer
class.
valueOf
from the String
class.
class LocalActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { if (e.getSource() == text field or button) { ... appropriate response ...; } else if (e.getSource() == another text field or button) { ... appropriate response ...; ... } } }
and then add the listener to the text or button field:
text field or button.addActionListener( new LocalActionListener() );
setLayout(new GridLayout(rows, columns, row spacing, column spacing) ); ... add(text field or button) ...
firePropertyChange
method to create
PropertyChangeEvent
instances and call property-change listeners.
PropertyChangeListener
interface,
then define the propertyChange
method, and then connect an
instance of your listener to a property-change-firing component using
the addPropertyChangeListener
method.