monjoes
asked on
disable input of text in a Jfilechooser
Dear all,
We have passed in the filename to a JFileChooser so that it display the filename we want, does anyone know how to block the user from changing the filename or to block the input?
Thanks
Joey
We have passed in the filename to a JFileChooser so that it display the filename we want, does anyone know how to block the user from changing the filename or to block the input?
Thanks
Joey
There is a reason (for SUN) to always enable user input: you can't choose a root (e.g. C:\)
without typing.
If you don't want the user to change the preset, why not compare the selection against the preset?
;JOOP!
without typing.
If you don't want the user to change the preset, why not compare the selection against the preset?
;JOOP!
>> you can't choose a root
You can select it by browing thru the available list in the filechooser.
You can select it by browing thru the available list in the filechooser.
ASKER
Thanks Sciuriware,
But we don't want the user to change the text at all.
But we don't want the user to change the text at all.
All you can do is set the edit field to non editable.
But you can't access that component.
Remain 2 options: indeed write your own chooser based on JDialog (not so difficult as it seems),
add actionlisteners and find out which one reports an edit attempt so you can reset it.
;JOOP!
But you can't access that component.
Remain 2 options: indeed write your own chooser based on JDialog (not so difficult as it seems),
add actionlisteners and find out which one reports an edit attempt so you can reset it.
;JOOP!
Already given options ;)
Maybe interesting: "Customizing JFileChooser": http://java.sun.com/developer/JDCTechTips/2004/tt0316.html
There must be a way to get (and disable) that filename TextField...
There must be a way to get (and disable) that filename TextField...
>> But we don't want the user to change the text at all
Then why do you want to use the JFileChooser in the first place? It is a file-chooser -> mean to choose files - and you don't want to do that. When you already have the file-name with you, just use it. Why to display the JFileChooser?
Then why do you want to use the JFileChooser in the first place? It is a file-chooser -> mean to choose files - and you don't want to do that. When you already have the file-name with you, just use it. Why to display the JFileChooser?
ASKER
Just let them to choose the path
Then you need to set it so that it only allows to choose directories
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This will filter out the directory only listing or file only or both.
It is nothing to do with the Text field.
It is nothing to do with the Text field.
monjoes, what you need is a JFileChooser with the setting above (DIRECTORIES_ONLY)
and with a file filter that only accepts a directory with the file in it that you want.
It's easier for you NOT to put the filename in the chooser but on a label above it.
;JOOP!
and with a file filter that only accepts a directory with the file in it that you want.
It's easier for you NOT to put the filename in the chooser but on a label above it.
;JOOP!
try this...
http://archives.real-time.com/pipermail/jserv-devel/2000-June/000051.html
http://jan.netcomp.monash.edu.au/java/swingtut/tut2.html
best of luck..
R.K.
http://archives.real-time.com/pipermail/jserv-devel/2000-June/000051.html
http://jan.netcomp.monash.edu.au/java/swingtut/tut2.html
best of luck..
R.K.
Since at last it became clear that the author wanted to use the JFileChooser
>> Just let them to choose the path
I think my comment
>> Then you need to set it so that it only allows to choose directories
(+explanation how to do that in the following comment)
is a valid candidate for the accepted answer.
>> Just let them to choose the path
I think my comment
>> Then you need to set it so that it only allows to choose directories
(+explanation how to do that in the following comment)
is a valid candidate for the accepted answer.
Regards,
Muruga