From cde9afa09186226445e6d99a89baff9ec523a876 Mon Sep 17 00:00:00 2001 From: Campbell Suter Date: Thu, 20 Oct 2016 12:49:58 +1300 Subject: [PATCH] Make keybound buttons cache their text, in case the keys are changed midgame --- .../src/main/java/mage/client/components/KeyboundButton.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/components/KeyboundButton.java b/Mage.Client/src/main/java/mage/client/components/KeyboundButton.java index 3e0516f726e..c1f806cd712 100644 --- a/Mage.Client/src/main/java/mage/client/components/KeyboundButton.java +++ b/Mage.Client/src/main/java/mage/client/components/KeyboundButton.java @@ -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;