Browse Source

Use model instead JToggleButton cast.

master
Hendrik Schreiber 8 years ago
parent
commit
ea4d568d13
  1. 10
      src/com/bulenkov/darcula/ui/DarculaButtonUI.java

10
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");

Loading…
Cancel
Save