-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGui.java
More file actions
37 lines (34 loc) · 1.2 KB
/
Copy pathGui.java
File metadata and controls
37 lines (34 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package CheckBox62;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
public class Gui extends JFrame{ //inherits everything from JFrame
private JButton reg;
private JButton custom;
//constructor
public Gui(){
super("The title");
setLayout(new FlowLayout()); // default Layout
reg = new JButton("reg Button");
add(reg);
Icon b = new ImageIcon(getClass().getResource("b.png"));
Icon x = new ImageIcon(getClass().getResource("x.png"));
custom = new JButton("Custom", b);
custom.setRolloverIcon(x);
add(custom);
HandlerClass handler = new HandlerClass();
reg.addActionListener(handler);
custom.addActionListener(handler);
}
private class HandlerClass implements ActionListener{
//implements means uses methods but has to overwrite them!
public void actionPerformed(ActionEvent event){
JOptionPane.showMessageDialog(null,String.format("%s",event.getActionCommand()));
}
}
}