Skip to content

Instantly share code, notes, and snippets.

@Ricordel
Created August 23, 2013 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ricordel/6324415 to your computer and use it in GitHub Desktop.
Save Ricordel/6324415 to your computer and use it in GitHub Desktop.
Java button
import javax.swing.*;
import java.awt.event.*;
public class Bouton
{
static int i = 0;
static JButton button;
static JFrame mainWindow;
public static void main(String[] args)
{
mainWindow = new JFrame();
button = new JButton("Cliquez-moi !");
button.addActionListener(new ActionListener() { // you said verbose ?
public void actionPerformed(ActionEvent e) {
i++;
button.setText("Cliqué " + i + " fois");
}
});
mainWindow.add(button);
mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Yes, it's not by default...
mainWindow.pack();
mainWindow.setSize(200, 200);
mainWindow.show(true); // Not by default either
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment