Exemple #1
2
 /**
  * Returns a border instance for a Windows ToolBar
  *
  * @return a border used for the toolbar
  * @since 1.4
  */
 public static Border getToolBarBorder() {
   UIDefaults table = UIManager.getLookAndFeelDefaults();
   Border toolBarBorder =
       new WindowsBorders.ToolBarBorder(
           table.getColor("ToolBar.shadow"), table.getColor("ToolBar.highlight"));
   return toolBarBorder;
 }
Exemple #2
0
  public static class BevelBorder extends AbstractBorder implements UIResource {
    private Color darkShadow = UIManager.getColor("controlShadow");
    private Color lightShadow = UIManager.getColor("controlLtHighlight");
    private boolean isRaised;

    public BevelBorder(boolean isRaised, Color darkShadow, Color lightShadow) {
      this.isRaised = isRaised;
      this.darkShadow = darkShadow;
      this.lightShadow = lightShadow;
    }

    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      g.setColor((isRaised) ? lightShadow : darkShadow);
      g.drawLine(x, y, x + w - 1, y); // top
      g.drawLine(x, y + h - 1, x, y + 1); // left

      g.setColor((isRaised) ? darkShadow : lightShadow);
      g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); // bottom
      g.drawLine(x + w - 1, y + h - 1, x + w - 1, y + 1); // right
    }

    public Insets getBorderInsets(Component c, Insets insets) {
      insets.set(1, 1, 1, 1);
      return insets;
    }

    public boolean isOpaque(Component c) {
      return true;
    }
  }
Exemple #3
0
    /**
     * Draws the FrameBorder in the given Rect. Calls <b>drawTitleBar</b>, <b>drawLeftBorder</b>,
     * <b>drawRightBorder</b> and <b>drawBottomBorder</b>.
     */
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
      if (isActiveFrame()) {
        frameColor = UIManager.getColor("activeCaptionBorder");
      } else {
        frameColor = UIManager.getColor("inactiveCaptionBorder");
      }
      frameHighlight = frameColor.brighter();
      frameShadow = frameColor.darker().darker();

      drawTopBorder(c, g, x, y, width, height);
      drawLeftBorder(c, g, x, y, width, height);
      drawRightBorder(c, g, x, y, width, height);
      drawBottomBorder(c, g, x, y, width, height);
    }
Exemple #4
0
 /**
  * Returns a border instance for a Windows Progress Bar
  *
  * @since 1.4
  */
 public static Border getProgressBarBorder() {
   UIDefaults table = UIManager.getLookAndFeelDefaults();
   Border progressBarBorder =
       new BorderUIResource.CompoundBorderUIResource(
           new WindowsBorders.ProgressBarBorder(
               table.getColor("ProgressBar.shadow"), table.getColor("ProgressBar.highlight")),
           new EmptyBorder(1, 1, 1, 1));
   return progressBarBorder;
 }
Exemple #5
0
 public static Border getTableHeaderBorder() {
   UIDefaults table = UIManager.getLookAndFeelDefaults();
   Border tableHeaderBorder =
       new BorderUIResource.CompoundBorderUIResource(
           new BasicBorders.ButtonBorder(
               table.getColor("Table.shadow"),
               table.getColor("Table.darkShadow"),
               table.getColor("Table.light"),
               table.getColor("Table.highlight")),
           new BasicBorders.MarginBorder());
   return tableHeaderBorder;
 }
Exemple #6
0
  public static Border getInternalFrameBorder() {
    UIDefaults table = UIManager.getLookAndFeelDefaults();
    Border internalFrameBorder =
        new BorderUIResource.CompoundBorderUIResource(
            BorderFactory.createBevelBorder(
                BevelBorder.RAISED,
                table.getColor("InternalFrame.borderColor"),
                table.getColor("InternalFrame.borderHighlight"),
                table.getColor("InternalFrame.borderDarkShadow"),
                table.getColor("InternalFrame.borderShadow")),
            new WindowsBorders.InternalFrameLineBorder(
                table.getColor("InternalFrame.activeBorderColor"),
                table.getColor("InternalFrame.inactiveBorderColor"),
                table.getInt("InternalFrame.borderWidth")));

    return internalFrameBorder;
  }
Exemple #7
0
  public static class ButtonBorder extends AbstractBorder implements UIResource {
    protected Color focus = UIManager.getColor("activeCaptionBorder");
    protected Color shadow = UIManager.getColor("Button.shadow");
    protected Color highlight = UIManager.getColor("Button.light");
    protected Color darkShadow;

    public ButtonBorder(Color shadow, Color highlight, Color darkShadow, Color focus) {
      this.shadow = shadow;
      this.highlight = highlight;
      this.darkShadow = darkShadow;
      this.focus = focus;
    }

    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      boolean isPressed = false;
      boolean hasFocus = false;
      boolean canBeDefault = false;
      boolean isDefault = false;

      if (c instanceof AbstractButton) {
        AbstractButton b = (AbstractButton) c;
        ButtonModel model = b.getModel();

        isPressed = (model.isArmed() && model.isPressed());
        hasFocus = (model.isArmed() && isPressed) || (b.isFocusPainted() && b.hasFocus());
        if (b instanceof JButton) {
          canBeDefault = ((JButton) b).isDefaultCapable();
          isDefault = ((JButton) b).isDefaultButton();
        }
      }
      int bx1 = x + 1;
      int by1 = y + 1;
      int bx2 = x + w - 2;
      int by2 = y + h - 2;

      if (canBeDefault) {
        if (isDefault) {
          g.setColor(shadow);
          g.drawLine(x + 3, y + 3, x + 3, y + h - 4);
          g.drawLine(x + 3, y + 3, x + w - 4, y + 3);

          g.setColor(highlight);
          g.drawLine(x + 4, y + h - 4, x + w - 4, y + h - 4);
          g.drawLine(x + w - 4, y + 3, x + w - 4, y + h - 4);
        }
        bx1 += 6;
        by1 += 6;
        bx2 -= 6;
        by2 -= 6;
      }

      if (hasFocus) {
        g.setColor(focus);
        if (isDefault) {
          g.drawRect(x, y, w - 1, h - 1);
        } else {
          g.drawRect(bx1 - 1, by1 - 1, bx2 - bx1 + 2, by2 - by1 + 2);
        }
      }

      g.setColor(isPressed ? shadow : highlight);
      g.drawLine(bx1, by1, bx2, by1);
      g.drawLine(bx1, by1, bx1, by2);

      g.setColor(isPressed ? highlight : shadow);
      g.drawLine(bx2, by1 + 1, bx2, by2);
      g.drawLine(bx1 + 1, by2, bx2, by2);
    }

    public Insets getBorderInsets(Component c, Insets insets) {
      int thickness = (c instanceof JButton && ((JButton) c).isDefaultCapable()) ? 8 : 2;
      insets.set(thickness, thickness, thickness, thickness);
      return insets;
    }
  }