-
-
Save uncoded-ro/594ddd7644f695d7fc99dea1deb80131 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 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