Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Created January 9, 2020 10:58
Show Gist options
  • Save uncoded-ro/3c8cdb86c5993565e08184510fbf5a65 to your computer and use it in GitHub Desktop.
Save uncoded-ro/3c8cdb86c5993565e08184510fbf5a65 to your computer and use it in GitHub Desktop.
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