Java Swing Border suppressBorders(JComponent comp)

Here you can find the source of suppressBorders(JComponent comp)

Description

Nullify the border of this JComponent, as well as its subcomponents.

License

Open Source License

Declaration

public static void suppressBorders(JComponent comp) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.awt.Component;
import java.awt.Container;

import javax.swing.JButton;
import javax.swing.JComponent;

import javax.swing.JToggleButton;

public class Main {
    /**/*  w  ww.  j a  va2s .  com*/
     * Browse the whole hierarchy of components and nullify their
     * borders.
     */
    public static void suppressBorders(Container container) {
        for (Component comp : container.getComponents()) {
            if (comp instanceof JComponent) {
                suppressBorders((JComponent) comp);
            } else if (comp instanceof Container) {
                suppressBorders((Container) comp);
            }
        }
    }

    /**
     * Nullify the border of this JComponent, as well as its
     * subcomponents.
     */
    public static void suppressBorders(JComponent comp) {
        if (!(comp instanceof JButton) && !(comp instanceof JToggleButton)) {
            comp.setBorder(null);
        }

        suppressBorders((Container) comp);
    }
}

Related

  1. setBorder(JComponent comp, Border border)
  2. setDebugBorder(final JComponent component)
  3. setDefaultComponentsTabOrder(Vector v)
  4. setViewportBorder(JScrollPane scrollPane, int vertical, int horizontal)
  5. showBorder(JComponent c, Color color)