Java Swing LineBorder drawBorders(final JPanel panel)

Here you can find the source of drawBorders(final JPanel panel)

Description

Draw borders around the given JPanel and all descendants.

License

Open Source License

Parameter

Parameter Description
panel the panel to draw borders on

Declaration

public static void drawBorders(final JPanel panel) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.JPanel;

public class Main {
    /**/*from ww w.  j  a  v  a 2  s. co m*/
     * Draw borders around the given {@link JPanel} and all descendants.
     * @param panel the panel to draw borders on
     */
    public static void drawBorders(final JPanel panel) {
        panel.setBorder(BorderFactory.createLineBorder(Color.RED));
        final Component[] components = panel.getComponents();
        for (final Component comp : components) {
            if (comp instanceof JPanel) {
                drawBorders((JPanel) comp);
            }
        }
        panel.revalidate();
    }
}

Related

  1. changeBorder(JComponent field, Object fieldValue, PropertyChangeEvent e)
  2. createDebugBorder()
  3. createLineBorder()
  4. createPanelBorder()
  5. createThickInsetBorder()
  6. getBorderBlue()
  7. getDefaultLineBorder()
  8. getLineBorder()
  9. getMandatoryBorder()