ボタン押すと・・・・系

最も基礎レベルのコードがこれ

public class Main extends JFrame {
 Main() {
  setSize(200, 200);
  setLocationRelativeTo(null);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  JPanel pnl = new JPanel();
  JButton btn = new JButton("押して・・・・");
  pnl.add(btn);
  Container contentPane = getContentPane();
  contentPane.add(pnl, BorderLayout.CNETER);
 
  MyListener ml = new MyListener();//@
  btn.addActionListener(ml);//A
 }
 public static void main(String[] args) {
  Main ma = new Main();
  ma.setVisible(true);
 }
}
class MyListener implements ActionListener {//B
 public void actionPerformed(ActionEvent e) {
  System.out.println("あ〜ん");
 }
}