javax.swing.border.Border#paintBorder ( )源码实例Demo

下面列出了javax.swing.border.Border#paintBorder ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: seaglass   文件: SeaGlassBrowser.java
static void printBorder(PrintWriter html, Border border) {
    Insets insets = border.getBorderInsets(new JToolBar());
    html.println("<td>Border Insets(" + insets.top + "," + insets.left + "," + insets.bottom + "," + insets.right
            + ")</pre></td>");
    int w = 50 + insets.left + insets.right;
    int h = 20 + insets.top + insets.bottom;
    try {
        BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = img.createGraphics();
        Composite old = g2.getComposite();
        g2.setComposite(AlphaComposite.Clear);
        g2.fillRect(0, 0, w, h);
        g2.setComposite(old);
        g2.setColor(Color.RED);
        g2.fillRect(insets.left, insets.top, 49, 19);
        border.paintBorder(null, g2, 0, 0, w, h);
        g2.dispose();
        html.println("<td>" + saveImage(img) + "</td>");
    } catch (Exception e) {
        // e.printStackTrace();
        html.println("<td>NPE&nbsp;</td>");
    }
}
 
@Override
protected void paintBorder(Graphics g) {
	Border buttonBorder = getBorder();
	if (buttonBorder == null) {
		return;
	}

	Insets borderInsets = buttonBorder.getBorderInsets(this);
	int leftIconWidth = primaryIcon.getIconWidth() + (borderInsets.left + borderInsets.right);
	if (iconBorderEnabled) {
		buttonBorder.paintBorder(this, g, 0, 0, leftIconWidth, getHeight());
	}

	int rightButtonWidth =
		ARROW_WIDTH + ARROW_PADDING + (borderInsets.left + borderInsets.right);
	buttonBorder.paintBorder(this, g, leftIconWidth, 0, rightButtonWidth, getHeight());
}
 
源代码3 项目: netbeans   文件: LinkButton.java
@Override
protected void paintComponent(Graphics g) {
    Graphics2D g2 = Utils.prepareGraphics( g );
    if( showBorder && !Utils.isDefaultButtons() ) {
        Border b = underline ? mouseoverBorder : regularBorder;
        b.paintBorder(this, g, 0, 0, getWidth(), getHeight());
    }
    super.paintComponent(g2);

    if( showBorder && Utils.isDefaultButtons() )
        return;

    Dimension size = getSize();
    if( hasFocus() && isEnabled() ) {
        g2.setStroke( LINK_IN_FOCUS_STROKE );
        g2.setColor( Utils.getFocusedLinkColor() );
        g2.drawRect( 0, 0, size.width - 1, size.height - 1 );
    }
}
 
源代码4 项目: openjdk-jdk8u-backup   文件: Test6978482.java
public static void main(String[] args) {
    Component c = new Component() {};
    c.setBackground(Color.WHITE);
    c.setForeground(Color.BLACK);
    Graphics g = new BufferedImage(1024, 768, BufferedImage.TYPE_INT_RGB).getGraphics();
    g.setClip(0, 0, 1024, 768);
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        border.getBorderInsets(c);
        border.paintBorder(c, g, 0, 0, 1024, 768);
    }
}
 
源代码5 项目: FlatLaf   文件: FlatTitlePane.java
@Override
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
	// if menu bar is embedded, paint menu bar border
	Border menuBarBorder = getMenuBarBorder();
	if( menuBarBorder != null )
		menuBarBorder.paintBorder( c, g, x, y, width, height );

	if( hasJBRCustomDecoration() )
		JBRWindowTopBorder.getInstance().paintBorder( c, g, x, y, width, height );
}
 
源代码6 项目: dragonwell8_jdk   文件: BasicSplitPaneDivider.java
/**
 * Paints the divider.
 */
public void paint(Graphics g) {
  super.paint(g);

  // Paint the border.
  Border   border = getBorder();

  if (border != null) {
      Dimension     size = getSize();

      border.paintBorder(this, g, 0, 0, size.width, size.height);
  }
}
 
源代码7 项目: jdk8u-dev-jdk   文件: BasicSplitPaneDivider.java
/**
 * Paints the divider.
 */
public void paint(Graphics g) {
  super.paint(g);

  // Paint the border.
  Border   border = getBorder();

  if (border != null) {
      Dimension     size = getSize();

      border.paintBorder(this, g, 0, 0, size.width, size.height);
  }
}
 
源代码8 项目: TencentKona-8   文件: BasicSplitPaneDivider.java
/**
 * Paints the divider.
 */
public void paint(Graphics g) {
  super.paint(g);

  // Paint the border.
  Border   border = getBorder();

  if (border != null) {
      Dimension     size = getSize();

      border.paintBorder(this, g, 0, 0, size.width, size.height);
  }
}
 
源代码9 项目: seaglass   文件: SeaGlassScrollPaneUI.java
protected void paint(SynthContext context, Graphics g) {
    Border vpBorder = scrollpane.getViewportBorder();
    if (vpBorder != null) {
        Rectangle r = scrollpane.getViewportBorderBounds();
        vpBorder.paintBorder(scrollpane, g, r.x, r.y, r.width, r.height);
    }
}
 
源代码10 项目: Java8CN   文件: BasicSplitPaneDivider.java
/**
 * Paints the divider.
 */
public void paint(Graphics g) {
  super.paint(g);

  // Paint the border.
  Border   border = getBorder();

  if (border != null) {
      Dimension     size = getSize();

      border.paintBorder(this, g, 0, 0, size.width, size.height);
  }
}
 
源代码11 项目: jdk8u_jdk   文件: BasicSplitPaneDivider.java
/**
 * Paints the divider.
 */
public void paint(Graphics g) {
  super.paint(g);

  // Paint the border.
  Border   border = getBorder();

  if (border != null) {
      Dimension     size = getSize();

      border.paintBorder(this, g, 0, 0, size.width, size.height);
  }
}
 
源代码12 项目: Darcula   文件: DarculaSpinnerUI.java
@Override
public void paint(Graphics g, JComponent c) {
  super.paint(g, c);
  final Border border = spinner.getBorder();
  if (border != null) {
    border.paintBorder(c, g, 0, 0, spinner.getWidth(), spinner.getHeight());
  }
}
 
源代码13 项目: jdk8u60   文件: Test6978482.java
public static void main(String[] args) {
    Component c = new Component() {};
    c.setBackground(Color.WHITE);
    c.setForeground(Color.BLACK);
    Graphics g = new BufferedImage(1024, 768, BufferedImage.TYPE_INT_RGB).getGraphics();
    g.setClip(0, 0, 1024, 768);
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        border.getBorderInsets(c);
        border.paintBorder(c, g, 0, 0, 1024, 768);
    }
}
 
源代码14 项目: JDKSourceCode1.8   文件: BasicSplitPaneDivider.java
/**
 * Paints the divider.
 */
public void paint(Graphics g) {
  super.paint(g);

  // Paint the border.
  Border   border = getBorder();

  if (border != null) {
      Dimension     size = getSize();

      border.paintBorder(this, g, 0, 0, size.width, size.height);
  }
}
 
源代码15 项目: Zettelkasten   文件: MacSourceList.java
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    // if the item was selected, then paint the custom Mac selection background.
    if (fIsSelected) {
        Border backgroundPainter = fIsFocused
            ? UIManager.getBorder("List.sourceListFocusedSelectionBackgroundPainter")
            : UIManager.getBorder("List.sourceListSelectionBackgroundPainter");
        backgroundPainter.paintBorder(this, g, 0, 0, getWidth(), getHeight());
    }
}
 
源代码16 项目: openjdk-jdk9   文件: BasicSplitPaneDivider.java
/**
 * Paints the divider.
 */
public void paint(Graphics g) {
  super.paint(g);

  // Paint the border.
  Border   border = getBorder();

  if (border != null) {
      Dimension     size = getSize();

      border.paintBorder(this, g, 0, 0, size.width, size.height);
  }
}
 
源代码17 项目: java-swing-tips   文件: MainPanel.java
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  Border border = getBorder();
  String title = getTitle();
  if (Objects.isNull(title) || title.isEmpty() || Objects.isNull(border)) {
    super.paintBorder(c, g, x, y, width, height);
  } else {
    int edge = border instanceof TitledBorder ? 0 : EDGE_SPACING;
    JLabel lbl = getTitleLabel(c);
    Dimension size = lbl.getPreferredSize();
    Insets insets = makeComponentBorderInsets(border, c, new Insets(0, 0, 0, 0));

    int borderX = x + edge;
    int borderY = y + edge;
    int borderW = width - edge - edge;
    int borderH = height - edge - edge;

    int labelH = size.height;
    int labelW = height - insets.top - insets.bottom; // TEST: - (edge * 8);
    if (labelW > size.width) {
      labelW = size.width;
    }

    int left = edge + insets.left / 2 - labelH / 2;
    if (left < edge) {
      borderX -= left;
      borderW += left;
    }
    border.paintBorder(c, g, borderX, borderY, borderW, borderH);

    Graphics2D g2 = (Graphics2D) g.create();
    g2.translate(0, (height + labelW) / 2);
    g2.rotate(Math.toRadians(-90));
    // or: g2.transform(AffineTransform.getQuadrantRotateInstance(-1));
    lbl.setSize(labelW, labelH);
    lbl.paint(g2);
    g2.dispose();
  }
}
 
源代码18 项目: consulo   文件: ModernSpinnerUI.java
@Override
public void paint(Graphics g, JComponent c) {
  super.paint(g, c);
  final Border border = spinner.getBorder();
  if (border != null) {
    border.paintBorder(c, g, 0, 0, spinner.getWidth(), spinner.getHeight());
  }
}
 
源代码19 项目: jdk8u-jdk   文件: BasicSplitPaneDivider.java
/**
 * Paints the divider.
 */
public void paint(Graphics g) {
  super.paint(g);

  // Paint the border.
  Border   border = getBorder();

  if (border != null) {
      Dimension     size = getSize();

      border.paintBorder(this, g, 0, 0, size.width, size.height);
  }
}
 
源代码20 项目: jdk8u_jdk   文件: XTextAreaPeer.java
@Override
public void paint(Graphics g, JComponent c) {
    Border vpBorder = scrollpane.getViewportBorder();
    if (vpBorder != null) {
        Rectangle r = scrollpane.getViewportBorderBounds();
        vpBorder.paintBorder(scrollpane, g, r.x, r.y, r.width, r.height);
    }
}