Exemple #1
0
    private void paintOceanBorder(Component c, Graphics g, int x, int y, int w, int h) {
      AbstractButton button = (AbstractButton) c;
      ButtonModel model = ((AbstractButton) c).getModel();

      g.translate(x, y);
      if (MetalUtils.isToolBarButton(button)) {
        if (model.isEnabled()) {
          if (model.isPressed()) {
            g.setColor(MetalLookAndFeel.getWhite());
            g.fillRect(1, h - 1, w - 1, 1);
            g.fillRect(w - 1, 1, 1, h - 1);
            g.setColor(MetalLookAndFeel.getControlDarkShadow());
            g.drawRect(0, 0, w - 2, h - 2);
            g.fillRect(1, 1, w - 3, 1);
          } else if (model.isSelected() || model.isRollover()) {
            g.setColor(MetalLookAndFeel.getWhite());
            g.fillRect(1, h - 1, w - 1, 1);
            g.fillRect(w - 1, 1, 1, h - 1);
            g.setColor(MetalLookAndFeel.getControlDarkShadow());
            g.drawRect(0, 0, w - 2, h - 2);
          } else {
            g.setColor(MetalLookAndFeel.getWhite());
            g.drawRect(1, 1, w - 2, h - 2);
            g.setColor(UIManager.getColor("Button.toolBarBorderBackground"));
            g.drawRect(0, 0, w - 2, h - 2);
          }
        } else {
          g.setColor(UIManager.getColor("Button.disabledToolBarBorderBackground"));
          g.drawRect(0, 0, w - 2, h - 2);
        }
      } else if (model.isEnabled()) {
        boolean pressed = model.isPressed();
        boolean armed = model.isArmed();

        if ((c instanceof JButton) && ((JButton) c).isDefaultButton()) {
          g.setColor(MetalLookAndFeel.getControlDarkShadow());
          g.drawRect(0, 0, w - 1, h - 1);
          g.drawRect(1, 1, w - 3, h - 3);
        } else if (pressed) {
          g.setColor(MetalLookAndFeel.getControlDarkShadow());
          g.fillRect(0, 0, w, 2);
          g.fillRect(0, 2, 2, h - 2);
          g.fillRect(w - 1, 1, 1, h - 1);
          g.fillRect(1, h - 1, w - 2, 1);
        } else if (model.isRollover() && button.getClientProperty(NO_BUTTON_ROLLOVER) == null) {
          g.setColor(MetalLookAndFeel.getPrimaryControl());
          g.drawRect(0, 0, w - 1, h - 1);
          g.drawRect(2, 2, w - 5, h - 5);
          g.setColor(MetalLookAndFeel.getControlDarkShadow());
          g.drawRect(1, 1, w - 3, h - 3);
        } else {
          g.setColor(MetalLookAndFeel.getControlDarkShadow());
          g.drawRect(0, 0, w - 1, h - 1);
        }
      } else {
        g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
        g.drawRect(0, 0, w - 1, h - 1);
        if ((c instanceof JButton) && ((JButton) c).isDefaultButton()) {
          g.drawRect(1, 1, w - 3, h - 3);
        }
      }
    }