class MeineAktion implements ActionListener{ int i=0; JLabel l; MeineAktion(JLabel l){this.l=l;} public void actionPerformed(ActionEvent e){ i=i+1; l.setText(i+""); } }
JButton b=new JButton("drücken"); JLabel l = new JLabel("0"); b.addActionListener(new MeineAktion(l)); JPanel p=new JPanel(); p.add(b);p.add(l);