Java 8 Border - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Border class.

This code example shows how to use the following methods:getBorderInsets, paintBorder
    public boolean isBorderOpaque() { 
        return true; 
    } 
 
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        Insets borderInsets = border.getBorderInsets(c);
        Insets insets = getBorderInsets(c);
        int temp = (insets.top - borderInsets.top) / 2;
        border.paintBorder(c, g, x, y + temp, width, height - temp);
        Dimension size = comp.getPreferredSize();
        rect = new Rectangle(offset, 0, size.width, size.height);
        SwingUtilities.paintComponent(g, comp, (Container) c, rect);
    } 
 
    public Insets getBorderInsets(Component c) {
        Dimension size = comp.getPreferredSize();
        Insets insets = border.getBorderInsets(c);
        insets.top = Math.max(insets.top, size.height);
        return insets;
    } 

5
CodeRank
This code example shows how to use the following methods:getBorderInsets, paintBorder
This code example shows how to use the following methods:getBorderInsets, paintBorder
		return true; 
	} 
 
	public void paintBorder(Component c, Graphics g, int x, int y, int width,
			int height) {
		Insets borderInsets = border.getBorderInsets(c);
		Insets insets = getBorderInsets(c);
		int temp = (insets.top - borderInsets.top) / 2;
		border.paintBorder(c, g, x, y + temp, width, height - temp);
		Dimension size = comp.getPreferredSize();
		rect = new Rectangle(offset, 0, size.width, size.height);
		SwingUtilities.paintComponent(g, comp, (Container) c, rect);
	} 
 
	public Insets getBorderInsets(Component c) {
		Dimension size = comp.getPreferredSize();
		Insets insets = border.getBorderInsets(c);
		insets.top = Math.max(insets.top, size.height);
		return insets;
	} 

5
CodeRank
This code example shows how to use the following methods:getClass, getBorderInsets
        } 
        test(border, insets);
    } 
 
    private static void test(Border border, Insets insets) {
        Insets result = border.getBorderInsets(getComponent(border));
        if (insets == result) {
            throw new Error("both instances are the same for " + border.getClass());
        } 
        if (!insets.equals(result)) {
            throw new Error("both insets are not equal for " + border.getClass());
        } 
    } 
 
    private static JComponent getComponent(Border border) {
        Class type = border.getClass();
        if (type.equals(MotifBorders.MotifPopupMenuBorder.class)) {
            return POPUP;
        } 
        if (type.equals(WindowsBorders.ToolBarBorder.class)) {
            return TOOLBAR;
5
CodeRank
This code example shows how to use the following methods:getBorderInsets, paintBorder
 
        Border border = getBorder();
 
        if (getTitle() == null || getTitle().equals("")) {
            if (border != null) {
                border.paintBorder(c, g, x, y, width, height);
            } 
            return; 
        } 
 
        Rectangle grooveRect = new Rectangle(x, y, width, height);
        Font font = g.getFont();
        Color color = g.getColor();
 
        g.setFont(getFont(c));
 
        JComponent jc = (c instanceof JComponent) ? (JComponent) c : null;
        FontMetrics fm = SwingUtilities2.getFontMetrics(jc, g);
        int fontHeight = fm.getHeight();
        int descent = fm.getDescent();

4
CodeRank
This code example shows how to use the following methods:getBorderInsets, paintBorder
		@Override 
		public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
			Rectangle borderR = new Rectangle(x + EDGE_SPACING, y + EDGE_SPACING, width - (EDGE_SPACING * 2), height - (EDGE_SPACING * 2));
			Insets borderInsets;
			if (border != null) {
				borderInsets = border.getBorderInsets(c);
			} else { 
				borderInsets = new Insets(0, 0, 0, 0);
			} 
 
			Rectangle rect = new Rectangle(x, y, width, height);
			Insets insets = getBorderInsets(c);
			Rectangle compR = getComponentRect(rect, insets);
			int diff;
			switch (titlePosition) {
				case ABOVE_TOP:
					diff = compR.height + TEXT_SPACING;
					borderR.y += diff;
					borderR.height -= diff;
					break; 

4
CodeRank
This code example shows how to use the following methods:getBorderInsets, paintBorder
        if ((title != null) && !title.isEmpty()) {
            int edge = (border instanceof JideTitledBorder) ? 0 : EDGE_SPACING;
            JLabel label = getLabel(c);
            Dimension size = label.getPreferredSize();
            Insets insets = (border != null)
                    ? border.getBorderInsets(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 labelY = y;
            int labelH = size.height;
            int position = getPosition();
            switch (position) {
                case ABOVE_TOP:
                    insets.left = 0;
                    insets.right = 0;

4
CodeRank
This code example shows how to use the following methods:paintBorder
		TabPanePainter painter = getPane().getPainter();
		painter.paintForeground( g );
		 
		Border border = getBorder();
		if( border != null ){
			border.paintBorder( this, g, 0, 0, getWidth(), getHeight() );
		} 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:getBorderInsets, paintBorder
    public boolean isBorderOpaque() { 
        return true; 
    } 
 
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        Insets borderInsets = border.getBorderInsets(c);
        Insets insets = getBorderInsets(c);
        int temp = (insets.top - borderInsets.top) / 2;
        border.paintBorder(c, g, x, y + temp, width, height - temp);
        Dimension size = comp.getPreferredSize();
        rect = new Rectangle(offset, 0, size.width, size.height);
        SwingUtilities.paintComponent(g, comp, (Container)c, rect);
    } 
 
    public Insets getBorderInsets(Component c) {
        Dimension size = comp.getPreferredSize();
        Insets insets = border.getBorderInsets(c);
        insets.top = Math.max(insets.top, size.height);
        return insets;
    } 

4
CodeRank
This code example shows how to use the following methods:getBorderInsets
See Code Examples for Java 8 Border Methods: