]import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Test implements ActionListener
{
static JFrame myFrame;
static JButton myButton;
static JLabel messageLabel;
public static void main( String[] args )
{
int width = 100, height = 100;
Test myReference = new Test();
myButton = new JButton( "Button #1" );
messageLabel = new JLabel();
myFrame = new JFrame ( "My Game" );
myFrame.setSize ( width, height );
myFrame.setLayout ( new FlowLayout() );
myFrame.add ( myButton );
myFrame.add ( messageLabel );
myFrame.setVisible ( true );
myButton.addActionListener( myReference );
}
public void actionPerformed (ActionEvent referenceToTheActionEventClass )
{
int correctButtonNumber = 1;
String chosenButtonText;
chosenButtonText = referenceToTheActionEventClass.getActionCommand();
// I want to stop here.
correctButtonNumber = correctButtonNumber + 1;
chosenButtonText = chosenButtonText + correctButtonNumber;
messageLabel.setText( chosenButtonText );
}
}