Rename pressing to tinting. Change to behavior when leaving the rect will remove the tint (would stop tinting only when button released).

This commit is contained in:
John Hitchings 2019-03-10 23:12:48 -07:00
parent 11b93d0771
commit 5c01b38ed6
2 changed files with 18 additions and 7 deletions

View file

@ -15,7 +15,7 @@ public class KeyboundButton extends JButton {
private final String text;
private static final Font keyFont = new Font(Font.SANS_SERIF, Font.BOLD, 13);
private boolean pressing = false;
private boolean tinting = false;
public KeyboundButton(String key) {
text = PreferencesDialog.getCachedKeyText(key);
@ -27,11 +27,11 @@ public class KeyboundButton extends JButton {
Graphics sg = g.create();
try {
ui.update(sg, this);
if (pressing) {
if (tinting) {
sg.setColor(new Color(0, 0, 0, 32));
sg.fillRoundRect(2, 2, getWidth() - 4 , getHeight() - 4, 6, 6);
}
sg.setColor(pressing ? Color.lightGray : Color.white);
sg.setColor(tinting ? Color.lightGray : Color.white);
sg.setFont(keyFont);
int textWidth = sg.getFontMetrics(keyFont).stringWidth(text);
@ -44,8 +44,8 @@ public class KeyboundButton extends JButton {
}
}
public void setPressing(boolean pressing) {
this.pressing = pressing;
public void setTint(boolean tinting) {
this.tinting = tinting;
repaint();
}