 <p>Another way to do it:</p> <pre><code>JButton button = new JButton("1"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int count = Integer.parseInt(button.getLabel()); button.setLabel((String)count); } }); </code></pre>