-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuButton.java
More file actions
59 lines (49 loc) · 1.58 KB
/
MenuButton.java
File metadata and controls
59 lines (49 loc) · 1.58 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
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import java.awt.*;
public class MenuButton extends JButton {
public MenuButton() {
super();
setForeground(Color.DARK_GRAY);
setBackground(Color.WHITE);
Border line = new LineBorder(Color.BLACK);
Border margin = new EmptyBorder(5, 15, 5, 15);
Border compound = new CompoundBorder(line, margin);
setBorder(compound);
setFont(getFont().deriveFont(Font.BOLD, 50));
}
public MenuButton(String text) {
this();
setText(text);
}
public MenuButton(String iconPath, int height, int width) {
this();
setImage(iconPath, height, width);
}
public MenuButton(int level) {
this(Integer.toString(level));
}
public MenuButton(ImageIcon icon) {
}
public void setImage(String pImagePath, int width, int height) {
Image imgSettings = (new ImageIcon(pImagePath)).getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH);
ImageIcon icon = new ImageIcon(imgSettings);
setIcon(icon);
setOpaque(false);
setBackground(null);
setBorder(null);
setSize(icon.getIconWidth(), icon.getIconHeight());
setContentAreaFilled(false);
}
public void setLocked() {
setEnabled(false);
setImage("Content/Graphics/UI/lockIcon.png", 50, 50);
}
public void setUnlocked() {
setEnabled(true);
setIcon(null);
}
}