Here you can find the source of hideApproveButton(JFileChooser fileChooser)
public static void hideApproveButton(JFileChooser fileChooser)
//package com.java2s; //License from project: GNU General Public License import java.awt.Component; import java.awt.Container; import javax.swing.JButton; import javax.swing.JFileChooser; public class Main { public static void hideApproveButton(JFileChooser fileChooser) { // this will initialize the button and its parent component fileChooser.setApproveButtonText("approveButton"); JButton button = lookupButton(fileChooser, "approveButton"); // reset approve button text fileChooser.setApproveButtonText(null); // hide it button.setVisible(false);//from w w w .ja va2 s. com } /** * Find button by text * * @param c * @param text * @return */ private static JButton lookupButton(Container c, String text) { JButton button = null; for (Component comp : c.getComponents()) { if (comp == null) { continue; } if (comp instanceof JButton && (button = (JButton) comp).getText() != null && button.getText().equals(text)) { return button; } else if (comp instanceof Container) { if ((button = lookupButton((Container) comp, text)) != null) { return button; } } } return button; } }