import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Alphabet extends MouseAdapter {

  private JFrame capsFrame;
  private JButton capsButton;

  private static final int NUM_CHARS = 26;
  private static final int ASCII_A = 97;
  
  public Alphabet() {
    capsFrame = new JFrame();
    capsButton = new JButton();
    capsButton.setHorizontalAlignment(SwingConstants.CENTER);
    capsButton.setText("a");
    capsFrame.setSize(200,200);
    Container c = capsFrame.getContentPane();
    c.add(capsButton);
    capsButton.addMouseListener(this);
    capsFrame.setVisible(true);
  }
  
  public void mouseClicked (MouseEvent event) {
    String text = ((JButton) event.getComponent()).getText();
    char current =  text.charAt(0);
   
    char next = (char) (((int) current + 1 - ASCII_A) % NUM_CHARS + ASCII_A);
    capsButton.setText(next + "");
  } 
}