How do I tell my action listener to click a button and display the buttons text into a text area?
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if (e.getSource() instanceof JButton) {
String text = e.getActionCommand();
JOptionPane.showMessageDialog(null, text);
}
}
};
The JTextArea area
is initialized after the actionlistener and so when i try to define area.
it give me an error. Can you help me?