Java Swing LineBorder addDebugBorders(JPanel panel)

Here you can find the source of addDebugBorders(JPanel panel)

Description

Adds a one pixel border of random color to this and all panels contained in this panel's child hierarchy.

License

Open Source License

Declaration

public static void addDebugBorders(JPanel panel) 

Method Source Code


//package com.java2s;
import java.awt.Color;

import java.util.Random;
import javax.swing.BorderFactory;

import javax.swing.JPanel;

public class Main {
    /** Used by {@link #addDebugBorders}. */
    protected static final Random _rando = new Random();

    /**/*ww  w. j a  va  2s. c  o  m*/
     * Adds a one pixel border of random color to this and all panels contained in this panel's
     * child hierarchy.
     */
    public static void addDebugBorders(JPanel panel) {
        Color bcolor = new Color(_rando.nextInt(256), _rando.nextInt(256), _rando.nextInt(256));
        panel.setBorder(BorderFactory.createLineBorder(bcolor));

        for (int ii = 0; ii < panel.getComponentCount(); ii++) {
            Object child = panel.getComponent(ii);
            if (child instanceof JPanel) {
                addDebugBorders((JPanel) child);
            }
        }
    }
}

Related

  1. addBordersToLine(Component content)
  2. changeBorder(JComponent field, Object fieldValue, PropertyChangeEvent e)
  3. createDebugBorder()
  4. createLineBorder()
  5. createPanelBorder()