Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1093
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: JFileChooser |
| Message-ID | <1172888066.883410.208790@8g2000cwh.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <vkfhu2dmt31mbthc4dho2of1th0rgsbjg3@4ax.com> |
| Date | 2011-04-27 15:31 +0000 |
| Organization | TDS.net |
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
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web