Java JButton Settings setButtonInsetsRecursive(Insets insets, Container container)

Here you can find the source of setButtonInsetsRecursive(Insets insets, Container container)

Description

set Button Insets Recursive

License

Open Source License

Declaration

public static void setButtonInsetsRecursive(Insets insets,
            Container container) 

Method Source Code

//package com.java2s;
/*/*w  w w .ja  v a 2  s . com*/
 * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
 * All rights reserved. This program is made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 * Contributors:
 * General Robotix Inc.
 * National Institute of Advanced Industrial Science and Technology (AIST) 
 */

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

import java.awt.Insets;

import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JCheckBox;

import javax.swing.JRadioButton;

import javax.swing.JToggleButton;

public class Main {
    public static void setButtonInsetsRecursive(Insets insets,
            Container container) {
        Component[] components = container.getComponents();
        for (int i = 0; i < components.length; i++) {
            Component c = components[i];
            if (c instanceof JButton || c instanceof JToggleButton) {
                if (!(c instanceof JCheckBox)
                        && !(c instanceof JRadioButton))
                    ((AbstractButton) c).setMargin(insets);
            } else if (c instanceof Container)
                setButtonInsetsRecursive(insets, (Container) c);
        }
    }
}

Related

  1. setAllEnabled(final ButtonGroup buttonGroup, final boolean enabled)
  2. setAutoMnemonic(AbstractButton button)
  3. setBtnValue(ButtonGroup group, String value)
  4. setButton(AbstractButton button, Icon icon, ActionListener buttonListener)
  5. setButtonContentMargin(AbstractButton button, Insets margin)
  6. setButtonSelected(ButtonGroup buttonGroup, int selected)
  7. setButtonStyle(AbstractButton btn)
  8. setButtonText(ButtonGroup buttonGroup, List texts)
  9. setHelpIDString(javax.swing.AbstractButton btn, String id)