How to forbid directory name editing in JFileChooser?
Asked Answered
S

1

6

To browse directories in JFileChooser, users use double-click. The problem is, if they click not fast enough, file chooser thinks they want to edit directory name, and it is very annoying. Is there a way to disable directory name editing?

Sulfathiazole answered 31/8, 2011 at 8:49 Comment(5)
By doing this, you'll annoy users who can double-click and want the file choser to have this capability, to make the users unable to double-click a bit more happy (because they still have to double-click to open the folder).Lightship
@JB Nizet - yes, I understand. But on this specific project, they do not need it, they are annoyed, and accidental edit of directory name would lead to disaster.Sulfathiazole
If it's such a disaster if some directory name is changed, shouldn't it be forbidden at the OS level?Lightship
@JB Nizet - good idea! But it is not my field, so I would tell their admin.Sulfathiazole
@JB Nizet - and forbidding editing of dir name by permissions does not stop file chooser from going to edit mode.Sulfathiazole
L
8

You could set the file chooser to be read only, if need be:

UIManager.put("FileChooser.readOnly", Boolean.TRUE);

Unfortunately, that also removes the 'new folder' button, if I am correct.

Launceston answered 31/8, 2011 at 9:47 Comment(1)
Yes, it removes 'new folder', but it is no problem for me. Thanks!Sulfathiazole

© 2022 - 2024 — McMap. All rights reserved.