Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.awt.Color;
import java.awt.Component;

import javax.accessibility.AccessibleContext;

public class Main {
    private static void setBackground0(AccessibleContext ac, Color bg) {
        ac.getAccessibleComponent().setBackground(bg);
        int n = ac.getAccessibleChildrenCount();
        for (int i = 0; i < n; i++) {
            setBackground0(ac.getAccessibleChild(i).getAccessibleContext(), bg);
        }
    }

    /**
     * Recursively changes the background of a component and all its children.
     * @param c - The Root Component
     * @param bg - The Background Colour
     */
    public static void setBackground(Component c, Color bg) {
        setBackground0(c.getAccessibleContext(), bg);
    }
}