Java JButton Settings hideJFileChooserButtons(JFileChooser sessionFileChooser)

Here you can find the source of hideJFileChooserButtons(JFileChooser sessionFileChooser)

Description

hide J File Chooser Buttons

License

Open Source License

Declaration

public static void hideJFileChooserButtons(JFileChooser sessionFileChooser) 

Method Source Code


//package com.java2s;
//License from project: GNU General Public License 

import java.awt.Component;
import java.awt.Container;
import javax.swing.AbstractButton;

import javax.swing.JFileChooser;

public class Main {
    public static void hideJFileChooserButtons(JFileChooser sessionFileChooser) {
        // stupid graphical buttons do not seem to have anything better than tooltip for identification
        hideChildButtonsWithTooltip(sessionFileChooser, "Sessions at server");
        hideChildButtonsWithTooltip(sessionFileChooser, "Up One Level");
        hideChildButtonsWithTooltip(sessionFileChooser, "Remote sessions");
        hideChildButtonsWithTooltip(sessionFileChooser, "Create New Folder");
        hideChildButtonsWithTooltip(sessionFileChooser, "List");
        hideChildButtonsWithTooltip(sessionFileChooser, "Details");
    }/* w w  w .j a v a2 s. c om*/

    /**
     * Find button by tooltip
     * 
     * @param parent
     * @param tooltip
     */
    private static void hideChildButtonsWithTooltip(Container parent, String tooltip) {

        for (Component component : parent.getComponents()) {
            if (component instanceof AbstractButton
                    && tooltip.equals(((AbstractButton) component).getToolTipText())) {
                component.setVisible(false); // hide this
            } else if (component instanceof Container) {
                hideChildButtonsWithTooltip((Container) component, tooltip);
            }
        }

    }
}

Related

  1. groupButtons(final Container container, final boolean recursive)
  2. growFont(JComponent button)
  3. hasIcon(AbstractButton button)
  4. hasText(AbstractButton button)
  5. hideApproveButton(JFileChooser fileChooser)
  6. interButtonSpace()
  7. isScrollBarButton(AbstractButton button)
  8. isSelected(AbstractButton... buttons)
  9. isSelected(final AbstractButton abstractButton)