Java Code Examples for javax.swing.border.Border#paintBorder()

The following examples show how to use javax.swing.border.Border#paintBorder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicSplitPaneDivider.java    From jdk8u-jdk with GNU General Public License v2.0 7 votes vote down vote up
/**
 * 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);
  }
}
 
Example 2
Source File: SeaGlassBrowser.java    From seaglass with Apache License 2.0 6 votes vote down vote up
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>");
    }
}
 
Example 3
Source File: LinkButton.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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 );
    }
}
 
Example 4
Source File: MultipleActionDockingToolbarButton.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 5
Source File: DarculaSpinnerUI.java    From Darcula with Apache License 2.0 5 votes vote down vote up
@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());
  }
}
 
Example 6
Source File: XTextAreaPeer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 7
Source File: ModernSpinnerUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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());
  }
}
 
Example 8
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@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();
  }
}
 
Example 9
Source File: BasicSplitPaneDivider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 10
Source File: MacSourceList.java    From Zettelkasten with GNU General Public License v3.0 5 votes vote down vote up
@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());
    }
}
 
Example 11
Source File: BasicSplitPaneDivider.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 12
Source File: Test6978482.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example 13
Source File: Test6978482.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example 14
Source File: BasicSplitPaneDivider.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 15
Source File: BasicSplitPaneDivider.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 16
Source File: SeaGlassScrollPaneUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 17
Source File: BasicSplitPaneDivider.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 18
Source File: BasicSplitPaneDivider.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 19
Source File: BasicSplitPaneDivider.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 20
Source File: FlatTitlePane.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@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 );
}