-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainButton.java
More file actions
61 lines (42 loc) · 1.65 KB
/
MainButton.java
File metadata and controls
61 lines (42 loc) · 1.65 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import javax.swing.JButton;
import javax.swing.ImageIcon;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MainButton extends JButton{
protected GUI main_GUI;
public MainButton(String button_name, GUI m) {
super(button_name);
this.addActionListener(new button_click_handler(this));
this.main_GUI = m;
// setBackground(Color.black);
setContentAreaFilled(false);
setOpaque(true);
}
class button_click_handler implements ActionListener{
MainButton clicked_button;
public button_click_handler(MainButton clicked_button) {
this.clicked_button = clicked_button;
}
public void actionPerformed(ActionEvent e) {
for(MainButton button: main_GUI.button_list) {
button.setBackground(Color.WHITE);
// System.out.println("set white!");
}
clicked_button.setBackground(Color.GRAY);
main_GUI.clear_selected_list();
main_GUI.canvas_area.pressed_obj = null;
main_GUI.canvas_area.temp_line = null;
main_GUI.canvas_area.entered_obj = null;
main_GUI.current_clicked_button = clicked_button;
System.out.println(main_GUI.current_clicked_button.getClass().getName());
}
}
public void CanvasClickEvent(int x, int y) {}
public void CanvasPressEvent(int x, int y) {}
public void CanvasPressEvent(int x, int y, MainObject obj) {} //from object event
public void CanvasReleaseEvent(int x, int y) {}
public void CanvasReleaseEvent(int x, int y , MainObject obj) {}//from object event
public void CanvasEnterEvent(int x, int y , MainObject obj) {}//from object event
public void CanvasExitEvent(int x, int y , MainObject obj) {}//from object event
}