import javax.swing.*;
import static javax.swing.SwingUtilities.*;
import java.awt.*; import java.awt.event.*;

public class SeveralButtonsInner extends JFrame {
    private JLabel label;
    private JButton butA, butB;
    public class listenerA implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            label.setText("Toll! Knopf 1 mit Label "+
                   ((JButton)e.getSource()).getText());
    }   }
    public class listenerB implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            label.setText("Toll! Knopf 2 mit Label "+
                   ((JButton)e.getSource()).getText());
    }   }
    public SeveralButtonsInner() {
        setLayout(new FlowLayout()); 
        setSize(500,100);
        setVisible(true);
        setFont(new Font("SansSerif", Font.BOLD, 18));
        label = new JLabel();
        label.setText("Press key...");
        add(label);
        butA = new JButton("Knopf A");
        butA.addActionListener(new listenerA());
        add(butA);
        butB = new JButton("Knopf B");
        butB.addActionListener(new listenerB());
        add(butB);
    }
    public static void main(String args[]) {
        invokeLater(()->new SeveralButtonsInner());
}   }

