-
-
Save uncoded-ro/3c8cdb86c5993565e08184510fbf5a65 to your computer and use it in GitHub Desktop.
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
package ro.virtualcampus.ev; | |
import java.awt.*; | |
import java.awt.event.*; | |
import javax.swing.*; | |
public class Contor2 extends JFrame { | |
private static final long serialVersionUID = 1L; | |
JButton buton; | |
JLabel eticheta; | |
static int contor = 0; | |
public Contor2() { | |
super("Contor"); | |
setLocation(100, 100); | |
setLayout(new GridLayout(2, 1)); | |
buton = new JButton("Apasa!"); | |
eticheta = new JLabel("", JLabel.CENTER); | |
getContentPane().add(buton); | |
getContentPane().add(eticheta); | |
buton.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent e) { | |
if (e.getActionCommand().equals("Apasa!")) { | |
contor++; | |
eticheta.setText(contor + ""); | |
} | |
} | |
}); | |
} | |
public static void main(String args[]) { | |
Contor2 app = new Contor2(); | |
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
app.pack(); | |
app.setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment