From ea4d568d13a23bad4cc5760d0e5a7a625938b614 Mon Sep 17 00:00:00 2001 From: Hendrik Schreiber Date: Mon, 28 Nov 2016 16:21:11 +0100 Subject: [PATCH] Use model instead JToggleButton cast. --- src/com/bulenkov/darcula/ui/DarculaButtonUI.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/bulenkov/darcula/ui/DarculaButtonUI.java b/src/com/bulenkov/darcula/ui/DarculaButtonUI.java index 35abf1c..f9df5a0 100755 --- a/src/com/bulenkov/darcula/ui/DarculaButtonUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaButtonUI.java @@ -42,14 +42,16 @@ public class DarculaButtonUI extends BasicButtonUI { @Override public void paint(Graphics g, JComponent c) { + final AbstractButton button = (AbstractButton) c; + final ButtonModel model = button.getModel(); final Border border = c.getBorder(); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); final boolean square = isSquare(c); - if (c.isEnabled() && border != null && ((AbstractButton)c).isContentAreaFilled()) { + if (c.isEnabled() && border != null && button.isContentAreaFilled()) { final Insets ins = border.getBorderInsets(c); final int yOff = (ins.top + ins.bottom) / 4; if (!square) { - if (c instanceof JButton && ((JButton)c).isDefaultButton() || c instanceof JToggleButton && ((JToggleButton)c).isSelected()) { + if (c instanceof JButton && ((JButton)c).isDefaultButton() || model.isSelected()) { ((Graphics2D)g).setPaint(new GradientPaint(0, 0, getSelectedButtonColor1(), 0, c.getHeight(), getSelectedButtonColor2())); } else { @@ -63,8 +65,8 @@ public class DarculaButtonUI extends BasicButtonUI { } protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) { - AbstractButton button = (AbstractButton)c; - ButtonModel model = button.getModel(); + final AbstractButton button = (AbstractButton)c; + final ButtonModel model = button.getModel(); Color fg = button.getForeground(); if (fg instanceof UIResource && button instanceof JButton && ((JButton)button).isDefaultButton()) { final Color selectedFg = UIManager.getColor("Button.darcula.selectedButtonForeground");