Here you can find the source of hideJFileChooserButtons(JFileChooser sessionFileChooser)
public static void hideJFileChooserButtons(JFileChooser sessionFileChooser)
//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); } } } }