Created
August 23, 2013 21:54
-
-
Save Ricordel/6324415 to your computer and use it in GitHub Desktop.
Java button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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