This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Browse/Upload Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Browse/Upload Button" Watch "Browse/Upload Button" New topic
Author

Browse/Upload Button

Jim Cutler
Greenhorn

Joined: Oct 13, 2010
Posts: 2
How do you create a "Browse/Upload" Button in Java? I want to be able to click on the "Browse" button, upload a folder of files, and have that pathname stored into a textfield.

What do I put under my actionPerformed() method?
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 4092
    
  18

Check out JFileChooser.


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10747
    
    9

Bill ForJoe wrote:


Please check your private messages for an important administrative matter.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jim Cutler
Greenhorn

Joined: Oct 13, 2010
Posts: 2
How do I upload a folder of files? FileChooser only allows me to upload one individual file.
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Jim Cutler wrote:How do I upload a folder of files? FileChooser only allows me to upload one individual file.


You can use it to get a File or an array of File. Please look at the API for File and you'll see that it can represent a single File or directories. In fact the very first line in the API states that File is:
An abstract representation of file and directory pathnames.


So it should work fine for you if you let it.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 4092
    
  18

I'm a doctor, Jim...

Did you read the documentation?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Browse/Upload Button
 
It's not a secret anymore!