Java Utililty Methods Swing Border

List of utility methods to do Swing Border

Description

The list of methods to do Swing Border are organized into topic(s).

Method

JPanelgeneratePanelWithoutBorder()
generate Panel Without Border
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
return panel;
BordergetDefaultBorder()
get Default Border
return new JTextField().getBorder();
ColorgetDefaultBorderColour()
Convenience method for consistent border colour.
return UIManager.getColor("controlShadow");
BordergetTextFieldBorder()
get Text Field Border
return UIManager.getBorder("TextField.border");
BordergetToolTipBorder()
Gets the toolTipBorder attribute of the TapUtils class
return (Border) UIManager.get("ToolTip.border");
ShapegetWebBorderShape(final JComponent component, final int shadeWidth, final int round)
get Web Border Shape
if (round > 0) {
    return new RoundRectangle2D.Double(shadeWidth, shadeWidth, component.getWidth() - shadeWidth * 2 - 1,
            component.getHeight() - shadeWidth * 2 - 1, round * 2, round * 2);
} else {
    return new Rectangle2D.Double(shadeWidth, shadeWidth, component.getWidth() - shadeWidth * 2 - 1,
            component.getHeight() - shadeWidth * 2 - 1);
JPanelinitLineBorderPanel(Color color, Color lineColor)
Creates a gridbag layout panel with a line border
JPanel result = new JPanel();
result.setBackground(color);
result.setBorder(new LineBorder(lineColor, 1));
result.setLayout(new GridBagLayout());
return result;
voidinstallBorder(JComponent c, Border defaultBorder)
install Border
Border border = c.getBorder();
if (border == null || border instanceof UIResource) {
    c.setBorder(defaultBorder);
booleanisStandardBorder(Border b)
is Standard Border
if (b instanceof UIResource) {
    return true;
while (b instanceof CompoundBorder) {
    b = ((CompoundBorder) b).getInsideBorder();
return (b instanceof UIResource);
TitledBordermakeTitledBorder(JComponent panel, String title, Color color)
make Titled Border
TitledBorder result = BorderFactory.createTitledBorder(
        BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), title, TitledBorder.DEFAULT_JUSTIFICATION,
        TitledBorder.DEFAULT_POSITION, null, color);
panel.setBorder(result);
return result;