Disabling JFIleChooser Buttons

Is there any way to disable/remove the 'New Folder' button in a JFileChooser? I just want to choose a File and not be able to create new folders. Thanks in advance.
[173 byte] By [CaptainMorgan08a] at [2007-10-3 9:28:21]
# 1
fc = new JFileChooser(".");BasicFileChooserUI fcUI = (BasicFileChooserUI)fc.getUI();fcUI.getNewFolderAction().setEnabled(false);
Michael_Dunna at 2007-7-15 4:42:45 > top of Java-index,Desktop,Core GUI APIs...
# 2

afaik, if a user doesn't have a system permission to create a new folder in a given directory, the button will be disabled automatically. If a user can create folders, then disabling the button won't buy you anything excep pissing off those users who won't be able to do what they want and will have to switch back to the system.

dberanskya at 2007-7-15 4:42:45 > top of Java-index,Desktop,Core GUI APIs...
# 3
Thanks a lot!
CaptainMorgan08a at 2007-7-15 4:42:45 > top of Java-index,Desktop,Core GUI APIs...
# 4

> If a user can create

> folders, then disabling the button won't buy you

> anything excep pissing off those users who won't be

> able to do what they want and will have to switch

> back to the system.

That isnt the purpose of this JFileChooser. Im having the user select a file that is going to be edited later in the program. There is no point of the 'New Folder' button being there.

CaptainMorgan08a at 2007-7-15 4:42:45 > top of Java-index,Desktop,Core GUI APIs...
# 5

It's not pretty but works:

JFileChooser chooser = new JFileChooser();

disableCtrlBtn(chooser, "Create New Folder");

/*********/

void disableCtrlBtn(Container container, String btnTooltipText){

int cnt = container.getComponentCount();

for (int i=0; i<cnt; i++) {

Component comp = container.getComponent(i);

if (comp instanceof JButton){

JButton btn = (JButton)comp;

if (btn.getToolTipText().indexOf(btnTooltipText)>-1){

btn.setVisible(false);

return;

}

}

else if (comp instanceof JPanel)

disableCtrlBtn((Container) comp, btnTooltipText);

}

}

lenshia at 2007-7-15 4:42:45 > top of Java-index,Desktop,Core GUI APIs...