473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Hide "Files of type" label and combo box in a File Chooser

Hello,

I am trying to user a File Chooser with DIRECTORIES_ONLY set. And I would like to be able to hide the "Files of type" label and the associated combo box. I wonder if there is a way to do this programmatically or by using NetBeans?

Thank you for your help.

Akino.
Aug 2 '08 #1
3 3677
JosAH
11,448 Expert 8TB
I am trying to user a File Chooser with DIRECTORIES_ONLY set. And I would like to be able to hide the "Files of type" label and the associated combo box. I wonder if there is a way to do this programmatically or by using NetBeans?
I don't think NetBeans can be of any help here; you have to perform some
surgery on your JFileChooser. The following code snippet traverses through
all the Components of a chooser; you have to identify which ones you want to
hide and set to invisible:

Expand|Select|Wrap|Line Numbers
  1. JFileChooser chooser= ... ; // your chooser
  2. hideComponents(chooser.getComponents());
  3. ...
  4. private void hideComponents(Component[] components) {
  5.     // traverse through the components
  6.    for (int i= 0; i < components.length; i++) {
  7.       if (components[i] instanceof JPanel) // traverse recursively
  8.          hideComponents(components[i].getComponents())
  9.       else if ( /* identify component[i] */)
  10.          component[i].setVisible(false); // hide it
  11.    }
  12. }
  13.  
The code snippet avove iterates over all components of the chooser; if it finds
a JPanel, it calls itself recursively; if it finds one of your wanted components
it simply hides it.

kind regards,

Jos
Aug 3 '08 #2
Hello,

Thank you for your help.

I tried to use the code and got a compile-time error on the line :

.....................................
hideComponents(components[i].getComponents());
......................................

saying that it could not find the symbol "getComponents()". I wonder if there is another way to get a list of subcomponents?

Thanks, again.
Akino.
Aug 4 '08 #3
JosAH
11,448 Expert 8TB
I tried to use the code and got a compile-time error on the line :

.....................................
hideComponents(components[i].getComponents());
......................................

saying that it could not find the symbol "getComponents()". I wonder if there is another way to get a list of subcomponents?
My bad, that line should read:

Expand|Select|Wrap|Line Numbers
  1.  hideComponents(((JPanel)components[i]).getComponents());
  2.  
The component is a JPanel (it was tested in the previous if-clause) and a JPanel
does have such a method so that particular component should be cast to it.

kind regards,

Jos
Aug 5 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jesper Hermansen | last post by:
Hi! I'm making a system that will generate Winamp-playlists. To make it easy for the user to add a file to the list, I'm using <input type="file">. The problem with this is that I only get...
2
by: Matt | last post by:
If I do the following, the browse text box still cannot see C:/hello world/test.txt. <input type="file" name="fileName" value="C:/hello world/test.txt" size=80> Any ideas? and workarounds...
2
by: Laermans_k | last post by:
Hi, Does anyone have a solution to use the <input type="file" id="filechooser"> and the <input type="submit" id="submitbutton"> in 1 button click? I've already tried to create a javascript...
1
by: Mark Sandfox | last post by:
Is there a way to restrict the user to only selecting and sending either a ..gif or .jpg. Everything I have read says this option can not be done by design (security reasons). I find that irronic...
7
by: Drew Berkemeyer | last post by:
I've encounted a pretty strange problem and I'm not quite sure what to make of it. I have a web service that consumes an XML file as well as a few other parameters. This web service works fine...
2
by: IkBenHet | last post by:
Hello, I am uploading a file using this form in ASP.NET. I have also added a simpel textfield: <form runat="server" enctype="multipart/form-data"> <input type="file" id="oFile" Name="oFile"...
1
by: A.M-SG | last post by:
Hi, I am trying to simplify my app.config file. Can I have a section handler in a separated file? I am looking for something like this: <section name=".." type=".." file="..."> but it...
2
by: trint | last post by:
With the following code, I get the "message" whether or not there is content in my filefield: function check_file_field() { var file_field = document.getElementById("custCartFile");...
3
by: eeeeman | last post by:
This one has really got me! Im trying to write a value to a input type="file" form element using client-side javascript. I have tried the obvious, simply writing: <input type="file" ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.