Java Code Examples for javax.swing.border.AbstractBorder

The following examples show how to use javax.swing.border.AbstractBorder. These examples are extracted from open source projects. 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 Project: ghidra   Source File: DndTableCellRenderer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Insets getBorderInsets(Component c, Insets insets) {
	if (under == null) {
		throw new IllegalStateException("Must set under border");
	}
	if (under instanceof AbstractBorder) {
		// Repeat the sin from JComponent.java:1847 (OpenJDK-1.8.0_25)
		// that necessitate this method in the first place...
		return ((AbstractBorder) under).getBorderInsets(c, insets);
	}
	Insets temp = under.getBorderInsets(c);
	insets.top = temp.top;
	insets.left = temp.left;
	insets.bottom = temp.bottom;
	insets.right = temp.right;
	return insets;
}
 
Example 2
Source Project: weblaf   Source File: PainterSupport.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns {@link java.awt.Component.BaselineResizeBehavior} indicating how baseline of a {@link Component} changes when resized.
 *
 * @param component   {@link JComponent}
 * @param componentUI {@link ComponentUI}
 * @return {@link java.awt.Component.BaselineResizeBehavior} indicating how baseline of a {@link Component} changes when resized
 */
@NotNull
public static Component.BaselineResizeBehavior getBaselineResizeBehavior ( @NotNull final JComponent component,
                                                                           @NotNull final ComponentUI componentUI )
{
    final Component.BaselineResizeBehavior behavior;
    final Painter painter = getPainter ( component );
    if ( painter != null )
    {
        behavior = painter.getBaselineResizeBehavior ( component, componentUI );
    }
    else
    {
        final Border border = component.getBorder ();
        if ( border instanceof AbstractBorder )
        {
            final AbstractBorder abstractBorder = ( AbstractBorder ) border;
            behavior = abstractBorder.getBaselineResizeBehavior ( component );
        }
        else
        {
            behavior = Component.BaselineResizeBehavior.OTHER;
        }
    }
    return behavior;
}
 
Example 3
Source Project: dragonwell8_jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 4
Source Project: dragonwell8_jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 5
Source Project: TencentKona-8   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 6
Source Project: TencentKona-8   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 7
Source Project: jdk8u60   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 8
Source Project: jdk8u60   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 9
Source Project: openjdk-jdk8u   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 10
Source Project: openjdk-jdk8u   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 11
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 12
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 13
Source Project: openjdk-jdk9   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 14
Source Project: openjdk-jdk9   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 15
Source Project: jdk8u-jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 16
Source Project: jdk8u-jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 17
Source Project: hottub   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 18
Source Project: hottub   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 19
Source Project: openjdk-8-source   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 20
Source Project: openjdk-8-source   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 21
Source Project: openjdk-8   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 22
Source Project: openjdk-8   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 23
Source Project: jdk8u_jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 24
Source Project: jdk8u_jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 25
Source Project: jdk8u-jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 26
Source Project: jdk8u-jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 27
Source Project: seaglass   Source File: SeaGlassTableUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link Border} that paints any empty space to the right of the
 * last column header in the given {@link JTable}'s {@link JTableHeader}.
 *
 * @param  table DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
private static Border createTableHeaderEmptyColumnPainter(final JTable table) {
    return new AbstractBorder() {
        @Override
        public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
            // if this JTableHeader is parented in a JViewport, then paint
            // the table header background to the right of the last column
            // if neccessary.
            Container viewport = table.getParent();

            if ((viewport instanceof JViewport) && table.getWidth() < viewport.getWidth()) {
                int startX           = table.getWidth();
                int emptyColumnWidth = viewport.getWidth() - table.getWidth();

                TableCellRenderer renderer  = table.getTableHeader().getDefaultRenderer();
                // Rossi: Fix for indexoutofbounds exception: A try catch might be good too?
                Component         component = renderer.getTableCellRendererComponent(table, "", false, false, 0, table.getColumnCount()-1);

                component.setBounds(0, 0, emptyColumnWidth, table.getTableHeader().getHeight());

                ((JComponent) component).setOpaque(true);
                CELL_RENDER_PANE.paintComponent(g, component, null, startX, 0, emptyColumnWidth + 1,
                                                table.getTableHeader().getHeight(), true);
            }
        }
    };
}
 
Example 28
Source Project: jdk8u-dev-jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        test(border, border.getBorderInsets(getComponent(border)));
        if (border instanceof AbstractBorder) {
            test((AbstractBorder) border);
        }
    }
}
 
Example 29
Source Project: jdk8u-dev-jdk   Source File: Test4856008.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(AbstractBorder border) {
    Insets insets = new Insets(0, 0, 0, 0);
    if (insets != border.getBorderInsets(getComponent(border), insets)) {
        throw new Error("both instances are differ for " + border.getClass());
    }
    test(border, insets);
}
 
Example 30
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings("PMD.AvoidReassigningParameters")
private static Insets makeBorderInsets(Border border, Component c, Insets insets) {
  if (Objects.isNull(border)) {
    insets.set(0, 0, 0, 0);
  } else if (border instanceof AbstractBorder) {
    AbstractBorder ab = (AbstractBorder) border;
    insets = ab.getBorderInsets(c, insets);
  } else {
    Insets i = border.getBorderInsets(c);
    insets.set(i.top, i.left, i.bottom, i.right);
  }
  return insets;
}