Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Last active March 22, 2020 21:09
Show Gist options
  • Save uncoded-ro/594ddd7644f695d7fc99dea1deb80131 to your computer and use it in GitHub Desktop.
Save uncoded-ro/594ddd7644f695d7fc99dea1deb80131 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 TestEvent extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
private JButton buton1, buton2;
private JLabel text;
public TestEvent() {
super("TestEvent");
setLayout(new FlowLayout());
setLocation(100, 100);
buton1 = new JButton("Buton 1");
buton2 = new JButton("Buton 2");
text = new JLabel("Apasa un buton !");
getContentPane().add(buton1);
getContentPane().add(buton2);
getContentPane().add(text);
buton1.addActionListener(this);
buton2.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
text.setText(e.getActionCommand());
}
public static void main(String args[]) {
TestEvent app = new TestEvent();
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