- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquareButton.java
More file actions
Latest commit
27 lines (22 loc) · 783 Bytes
/
Copy pathSquareButton.java
File metadata and controls
27 lines (22 loc) · 783 Bytes
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
importjavax.swing.*;
importjava.awt.*;
importjavax.swing.border.EmptyBorder;
importjavax.swing.plaf.basic.BasicButtonUI;
publicclassSquareButtonextendsJButton {
privatestaticfinalColorBACKGROUND_COLOR = newColor(64, 64, 64);
publicstaticfinalintBUTTON_SIZE = 64;
publicSquareButton(Stringtext) {
super(text);
setFocusPainted(true);
setPreferredSize(newDimension(BUTTON_SIZE, BUTTON_SIZE));
setBackground(BACKGROUND_COLOR);
setBorder(newEmptyBorder(0, 0, 0, 0));
setUI(newBasicButtonUI());
}
@Override
publicDimensiongetPreferredSize() {
Dimensiond = super.getPreferredSize();
intsize = Math.max(d.width, d.height);
returnnewDimension(size, size);
}
}