Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1080 > unrolled thread
| Started by | "urpriya" <urpriya@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:31 +0000 |
| Last post | 2011-04-27 15:31 +0000 |
| Articles | 7 — 6 participants |
Back to article view | Back to comp.lang.java.gui
JFileChooser "urpriya" <urpriya@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: JFileChooser "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: JFileChooser "tar" <tar@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: JFileChooser "Hulker69" <hulker69@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: JFileChooser "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: JFileChooser "Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: JFileChooser a24900@googlemail.com.remove-dii-this - 2011-04-27 15:31 +0000
| From | "urpriya" <urpriya@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:31 +0000 |
| Subject | JFileChooser |
| Message-ID | <1172847168.272703.190590@n33g2000cwc.googlegroups.com> |
To: comp.lang.java.gui How can i disable the "File Name" TextFeild in JFileChooser? The file name present in the textfeild should not be editable.How can i do this? --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:31 +0000 |
| Message-ID | <1172847936.009276.223590@n33g2000cwc.googlegroups.com> |
| In reply to | #1080 |
To: comp.lang.java.gui On Mar 3, 1:52 am, urpr...@gmail.com wrote: > How can i disable the "File Name" TextFeild in JFileChooser? > The file name present in the textfeild should not be editable. If there is only one file that can possibly be loaded, it is not a 'choice' of file. Why not simply offer a JCheckBox in a JOptionPane e.g. "Load Default Settings?", and dispense with the file chooser completely? > How can i do this? Why would you ant to do this? Andrew T. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "tar" <tar@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:31 +0000 |
| Message-ID | <ymilkia5ker.fsf@sevak.isi.edu> |
| In reply to | #1082 |
To: comp.lang.java.gui "Andrew Thompson" <andrewthommo@gmail.com> writes: > On Mar 3, 1:52 am, urpr...@gmail.com wrote: > > How can i disable the "File Name" TextFeild in JFileChooser? > > The file name present in the textfeild should not be editable. > > If there is only one file that can possibly > be loaded, it is not a 'choice' of file. > Why not simply offer a JCheckBox in a > JOptionPane e.g. "Load Default Settings?", > and dispense with the file chooser > completely? Or else just set the FFileChooser to only accept directories. That would let the user choose a directory in which to read or write the file, but not have control over the filename itself. chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); -- Thomas A. Russ, USC/Information Sciences Institute --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Hulker69" <hulker69@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:31 +0000 |
| Message-ID | <vkfhu2dmt31mbthc4dho2of1th0rgsbjg3@4ax.com> |
| In reply to | #1080 |
To: comp.lang.java.gui On 2 Mar 2007 06:52:48 -0800, urpriya@gmail.com wrote: >How can i disable the "File Name" TextFeild in JFileChooser? >The file name present in the textfeild should not be editable.How can >i do this? Try this ((JTextComponent)((Container)((Container)((Container)((Container)getComponent(2)).getComponent(2))).getComponent(2)).getComponent(1)).setEnabled(false); in constructor of an extension to the JFileChooser class. It drills down into the component hierarchy of the JFileChooser class and finds the JTextComponent associated with the File Name. I used jdb (via Eclipse) to expose these compoents in the Swing classes. Of course Sun may change the JFileChooser w.r.t. this component hierarchy in the future, but it works as of JDK 1.6 --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:31 +0000 |
| Message-ID | <1172888066.883410.208790@8g2000cwh.googlegroups.com> |
| In reply to | #1091 |
To: comp.lang.java.gui
On Mar 3, 11:22 am, Hulker69 <x...@xxx.com> wrote:
> On 2 Mar 2007 06:52:48 -0800, urpr...@gmail.com wrote:
>
> >How can i disable the "File Name" TextFeild in JFileChooser?
...
> Try this
>
> ((JTextComponent)((Container)((Container)((Container)((Container)getComponent(2)).getComponent(2))).getComponent(2)).getComponent(1)).setEnabled(false);
>
I was about to comment that was very
fragile code, and ask..
> in constructor of an extension to the JFileChooser class.
...
> in the future, but it works as of JDK 1.6
..did it also work X-plat and X-plaf?
But I thought I'd do a quick test 'here'
before I commented.
<sscce>
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
class FileChooserTextField extends JFileChooser {
FileChooserTextField() {
super();
Component theComponent = ((JTextComponent)
((Container)((Container)((Container)((Container)
getComponent(2)).
getComponent(2))).
getComponent(2)).
getComponent(1));
System.out.println(theComponent);
}
public static void main(String[] args) {
System.out.println("java.version: " +
System.getProperty("java.version") );
JFileChooser filechooser = new FileChooserTextField();
}
}
</sscce>
<output>
java.version: 1.6.0
Exception in thread "main"
java.lang.ArrayIndexOutOfBoundsException:
No such child: 2
at java.awt.Container.getComponent(Container.java:281)
at FileChooserTextField.<init>(FileChooserTextField.java:9)
at FileChooserTextField.main(FileChooserTextField.java:20)
Press any key to continue . . .
</output>
..so I'll simply ask, on which OS, under
which PLAF, (of Java 1.6) *does* that work?
Andrew T.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:31 +0000 |
| Message-ID | <esam26$902$1@utornnr1pp.grouptelecom.net> |
| In reply to | #1093 |
To: comp.lang.java.gui Andrew Thompson wrote: > On Mar 3, 11:22 am, Hulker69 <x...@xxx.com> wrote: >> On 2 Mar 2007 06:52:48 -0800, urpr...@gmail.com wrote: >> >>> How can i disable the "File Name" TextFeild in JFileChooser? > ... >> Try this >> >> ((JTextComponent)((Container)((Container)((Container)((Container)getCompone!nt(2)).getComponent(2))).getComponent(2)).getComponent(1)).setEnabled(false!); >> > > I was about to comment that was very > fragile code, and ask.. Andrew, this is a very very very good point. Although, you can play the with knowledge of how the plaf was written at a certain point in time it may come back to bite you. Before you know it your code might be stuck in, for example, JDK 1.4 forever. Cheers, Dan Andrews - - - - - - - - - - - - - - - - - - - - - - - - - Ansir Development Limited http://www.ansir.ca - - - - - - - - - - - - - - - - - - - - - - - - - --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | a24900@googlemail.com.remove-dii-this |
|---|---|
| Date | 2011-04-27 15:31 +0000 |
| Message-ID | <1172918696.999592.67430@n33g2000cwc.googlegroups.com> |
| In reply to | #1080 |
To: comp.lang.java.gui On Mar 2, 3:52 pm, urpr...@gmail.com wrote: > How can i disable the "File Name" TextFeild in JFileChooser? > The file name present in the textfeild should not be editable.How can > i do this? Sounds like you try to establish some kind of security feature by restricting the file chooser. That won't work out. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web