Untitled
unknown
plain_text
4 years ago
954 B
7
Indexable
import java.awt.event.ActionEvent; import java.awt.GridLayout; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; public class MyFrame extends JFrame implements ActionListener { MyFrame () { System.out.println("Hi"); this.setLayout(new GridLayout(2,2,10,10)); JButton button = new JButton("Button"); JButton button2 = new JButton("Button2"); JButton button3 = new JButton("Button3"); JButton button4 = new JButton("Button4"); this.add(button); this.add(button2); this.add(button3); this.add(button4); // button.addActionListener(this); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { System.out.println("Hello world!"); } }); this.setSize(400,400); this.setVisible(true); } public void actionPerformed(ActionEvent arg0) { System.out.println("Button - actionPerformed"); } ; }
Editor is loading...