mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
Make keybound buttons cache their text, in case the keys are changed midgame
This commit is contained in:
parent
b4dc47fbc9
commit
cde9afa091
1 changed files with 2 additions and 3 deletions
|
@ -12,11 +12,11 @@ import mage.client.dialog.PreferencesDialog;
|
|||
*/
|
||||
public class KeyboundButton extends JButton {
|
||||
|
||||
private final String key;
|
||||
private final String text;
|
||||
private static final Font keyFont = new Font(Font.SANS_SERIF, Font.BOLD, 13);
|
||||
|
||||
public KeyboundButton(String key) {
|
||||
this.key = key;
|
||||
text = PreferencesDialog.getCachedKeyText(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,7 +28,6 @@ public class KeyboundButton extends JButton {
|
|||
sg.setColor(Color.white);
|
||||
sg.setFont(keyFont);
|
||||
|
||||
String text = PreferencesDialog.getCachedKeyText(key);
|
||||
int textWidth = sg.getFontMetrics(keyFont).stringWidth(text);
|
||||
int centerX = (getWidth() - textWidth) / 2;
|
||||
|
||||
|
|
Loading…
Reference in a new issue