Exemplo n.º 1
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   AbstractButton b = (AbstractButton) c;
   ButtonModel model = b.getModel();
   if (b.isSelected() == true) {
     g.fillRoundRect(x + 3, y + 3, getIconWidth() - 6, getIconHeight() - 6, 4, 4);
   }
 }
Exemplo n.º 2
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   AbstractButton b = (AbstractButton) c;
   ButtonModel model = b.getModel();
   boolean isSelected = model.isSelected();
   if (isSelected) {
     y = y - getIconHeight() / 2;
     g.drawLine(x + 9, y + 3, x + 9, y + 3);
     g.drawLine(x + 8, y + 4, x + 9, y + 4);
     g.drawLine(x + 7, y + 5, x + 9, y + 5);
     g.drawLine(x + 6, y + 6, x + 8, y + 6);
     g.drawLine(x + 3, y + 7, x + 7, y + 7);
     g.drawLine(x + 4, y + 8, x + 6, y + 8);
     g.drawLine(x + 5, y + 9, x + 5, y + 9);
     g.drawLine(x + 3, y + 5, x + 3, y + 5);
     g.drawLine(x + 3, y + 6, x + 4, y + 6);
   }
 }
Exemplo n.º 3
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   Icon lafIcon = getLaFIcon();
   if (lafIcon != null) {
     lafIcon.paintIcon(c, g, x, y);
     return;
   }
   assert menuItem == null || c == menuItem;
   Icon icon = getIcon();
   if (type == JCheckBoxMenuItem.class || type == JRadioButtonMenuItem.class) {
     AbstractButton b = (AbstractButton) c;
     if (b.isSelected()) {
       Part backgroundPart = Part.MP_POPUPCHECKBACKGROUND;
       Part part = Part.MP_POPUPCHECK;
       State backgroundState;
       State state;
       if (isEnabled(c, null)) {
         backgroundState = (icon != null) ? State.BITMAP : State.NORMAL;
         state =
             (type == JRadioButtonMenuItem.class) ? State.BULLETNORMAL : State.CHECKMARKNORMAL;
       } else {
         backgroundState = State.DISABLEDPUSHED;
         state =
             (type == JRadioButtonMenuItem.class)
                 ? State.BULLETDISABLED
                 : State.CHECKMARKDISABLED;
       }
       Skin skin;
       XPStyle xp = XPStyle.getXP();
       skin = xp.getSkin(c, backgroundPart);
       skin.paintSkin(g, x, y, getIconWidth(), getIconHeight(), backgroundState);
       if (icon == null) {
         skin = xp.getSkin(c, part);
         skin.paintSkin(g, x + OFFSET, y + OFFSET, state);
       }
     }
   }
   if (icon != null) {
     icon.paintIcon(c, g, x + OFFSET, y + OFFSET);
   }
 }
Exemplo n.º 4
0
    public void paintIcon(Component c, Graphics g, int x, int y) {
      AbstractButton b = (AbstractButton) c;
      ButtonModel model = b.getModel();
      XPStyle xp = XPStyle.getXP();

      if (xp != null) {
        Part part = Part.BP_RADIOBUTTON;
        Skin skin = xp.getSkin(b, part);
        State state;
        int index = 0;
        if (model.isSelected()) {
          state = State.CHECKEDNORMAL;
          if (!model.isEnabled()) {
            state = State.CHECKEDDISABLED;
          } else if (model.isPressed() && model.isArmed()) {
            state = State.CHECKEDPRESSED;
          } else if (model.isRollover()) {
            state = State.CHECKEDHOT;
          }
        } else {
          state = State.UNCHECKEDNORMAL;
          if (!model.isEnabled()) {
            state = State.UNCHECKEDDISABLED;
          } else if (model.isPressed() && model.isArmed()) {
            state = State.UNCHECKEDPRESSED;
          } else if (model.isRollover()) {
            state = State.UNCHECKEDHOT;
          }
        }
        skin.paintSkin(g, x, y, state);
      } else {
        // fill interior
        if ((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
          g.setColor(UIManager.getColor("RadioButton.background"));
        } else {
          g.setColor(UIManager.getColor("RadioButton.interiorBackground"));
        }
        g.fillRect(x + 2, y + 2, 8, 8);

        // outter left arc
        g.setColor(UIManager.getColor("RadioButton.shadow"));
        g.drawLine(x + 4, y + 0, x + 7, y + 0);
        g.drawLine(x + 2, y + 1, x + 3, y + 1);
        g.drawLine(x + 8, y + 1, x + 9, y + 1);
        g.drawLine(x + 1, y + 2, x + 1, y + 3);
        g.drawLine(x + 0, y + 4, x + 0, y + 7);
        g.drawLine(x + 1, y + 8, x + 1, y + 9);

        // outter right arc
        g.setColor(UIManager.getColor("RadioButton.highlight"));
        g.drawLine(x + 2, y + 10, x + 3, y + 10);
        g.drawLine(x + 4, y + 11, x + 7, y + 11);
        g.drawLine(x + 8, y + 10, x + 9, y + 10);
        g.drawLine(x + 10, y + 9, x + 10, y + 8);
        g.drawLine(x + 11, y + 7, x + 11, y + 4);
        g.drawLine(x + 10, y + 3, x + 10, y + 2);

        // inner left arc
        g.setColor(UIManager.getColor("RadioButton.darkShadow"));
        g.drawLine(x + 4, y + 1, x + 7, y + 1);
        g.drawLine(x + 2, y + 2, x + 3, y + 2);
        g.drawLine(x + 8, y + 2, x + 9, y + 2);
        g.drawLine(x + 2, y + 3, x + 2, y + 3);
        g.drawLine(x + 1, y + 4, x + 1, y + 7);
        g.drawLine(x + 2, y + 8, x + 2, y + 8);

        // inner right arc
        g.setColor(UIManager.getColor("RadioButton.light"));
        g.drawLine(x + 2, y + 9, x + 3, y + 9);
        g.drawLine(x + 4, y + 10, x + 7, y + 10);
        g.drawLine(x + 8, y + 9, x + 9, y + 9);
        g.drawLine(x + 9, y + 8, x + 9, y + 8);
        g.drawLine(x + 10, y + 7, x + 10, y + 4);
        g.drawLine(x + 9, y + 3, x + 9, y + 3);

        // indicate whether selected or not
        if (model.isSelected()) {
          if (model.isEnabled()) {
            g.setColor(UIManager.getColor("RadioButton.foreground"));
          } else {
            g.setColor(UIManager.getColor("RadioButton.shadow"));
          }
          g.fillRect(x + 4, y + 5, 4, 2);
          g.fillRect(x + 5, y + 4, 2, 4);
        }
      }
    }
Exemplo n.º 5
0
    public void paintIcon(Component c, Graphics g, int x0, int y0) {
      int width = getIconWidth();
      int height = getIconHeight();

      XPStyle xp = XPStyle.getXP();
      if (xp != null) {
        Skin skin = xp.getSkin(c, part);
        AbstractButton b = (AbstractButton) c;
        ButtonModel model = b.getModel();

        // Find out if frame is inactive
        JInternalFrame jif =
            (JInternalFrame) SwingUtilities.getAncestorOfClass(JInternalFrame.class, b);
        boolean jifSelected = (jif != null && jif.isSelected());

        State state;
        if (jifSelected) {
          if (!model.isEnabled()) {
            state = State.DISABLED;
          } else if (model.isArmed() && model.isPressed()) {
            state = State.PUSHED;
          } else if (model.isRollover()) {
            state = State.HOT;
          } else {
            state = State.NORMAL;
          }
        } else {
          if (!model.isEnabled()) {
            state = State.INACTIVEDISABLED;
          } else if (model.isArmed() && model.isPressed()) {
            state = State.INACTIVEPUSHED;
          } else if (model.isRollover()) {
            state = State.INACTIVEHOT;
          } else {
            state = State.INACTIVENORMAL;
          }
        }
        skin.paintSkin(g, 0, 0, width, height, state);
      } else {
        g.setColor(Color.black);
        int x = width / 12 + 2;
        int y = height / 5;
        int h = height - y * 2 - 1;
        int w = width * 3 / 4 - 3;
        int thickness2 = Math.max(height / 8, 2);
        int thickness = Math.max(width / 15, 1);
        if (part == Part.WP_CLOSEBUTTON) {
          int lineWidth;
          if (width > 47) lineWidth = 6;
          else if (width > 37) lineWidth = 5;
          else if (width > 26) lineWidth = 4;
          else if (width > 16) lineWidth = 3;
          else if (width > 12) lineWidth = 2;
          else lineWidth = 1;
          y = height / 12 + 2;
          if (lineWidth == 1) {
            if (w % 2 == 1) {
              x++;
              w++;
            }
            g.drawLine(x, y, x + w - 2, y + w - 2);
            g.drawLine(x + w - 2, y, x, y + w - 2);
          } else if (lineWidth == 2) {
            if (w > 6) {
              x++;
              w--;
            }
            g.drawLine(x, y, x + w - 2, y + w - 2);
            g.drawLine(x + w - 2, y, x, y + w - 2);
            g.drawLine(x + 1, y, x + w - 1, y + w - 2);
            g.drawLine(x + w - 1, y, x + 1, y + w - 2);
          } else {
            x += 2;
            y++;
            w -= 2;
            g.drawLine(x, y, x + w - 1, y + w - 1);
            g.drawLine(x + w - 1, y, x, y + w - 1);
            g.drawLine(x + 1, y, x + w - 1, y + w - 2);
            g.drawLine(x + w - 2, y, x, y + w - 2);
            g.drawLine(x, y + 1, x + w - 2, y + w - 1);
            g.drawLine(x + w - 1, y + 1, x + 1, y + w - 1);
            for (int i = 4; i <= lineWidth; i++) {
              g.drawLine(x + i - 2, y, x + w - 1, y + w - i + 1);
              g.drawLine(x, y + i - 2, x + w - i + 1, y + w - 1);
              g.drawLine(x + w - i + 1, y, x, y + w - i + 1);
              g.drawLine(x + w - 1, y + i - 2, x + i - 2, y + w - 1);
            }
          }
        } else if (part == Part.WP_MINBUTTON) {
          g.fillRect(x, y + h - thickness2, w - w / 3, thickness2);
        } else if (part == Part.WP_MAXBUTTON) {
          g.fillRect(x, y, w, thickness2);
          g.fillRect(x, y, thickness, h);
          g.fillRect(x + w - thickness, y, thickness, h);
          g.fillRect(x, y + h - thickness, w, thickness);
        } else if (part == Part.WP_RESTOREBUTTON) {
          g.fillRect(x + w / 3, y, w - w / 3, thickness2);
          g.fillRect(x + w / 3, y, thickness, h / 3);
          g.fillRect(x + w - thickness, y, thickness, h - h / 3);
          g.fillRect(x + w - w / 3, y + h - h / 3 - thickness, w / 3, thickness);

          g.fillRect(x, y + h / 3, w - w / 3, thickness2);
          g.fillRect(x, y + h / 3, thickness, h - h / 3);
          g.fillRect(x + w - w / 3 - thickness, y + h / 3, thickness, h - h / 3);
          g.fillRect(x, y + h - thickness, w - w / 3, thickness);
        }
      }
    }