Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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();

    /**
     * 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);
            }
        }
    }
}