-
-
Save uncoded-ro/6e32eb3a89714ef3dbf694238cf722f8 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.GridLayout; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.JButton; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
public class Contor3 extends JFrame { | |
private static final long serialVersionUID = 1L; | |
JButton buton; | |
JLabel eticheta; | |
static int contor = 0; | |
public Contor3() { | |
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 ButtonListener()); | |
} | |
class ButtonListener implements ActionListener { | |
public void actionPerformed(ActionEvent e) { | |
if (e.getActionCommand().equals("Apasa!")) { | |
contor++; | |
eticheta.setText(contor + ""); | |
} | |
} | |
} | |
public static void main(String args[]) { | |
Contor3 app = new Contor3(); | |
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