Solved

JFileChooser - multiple selections with mouse

Posted on 2009-07-01
6
1,267 Views
Last Modified: 2013-11-23
I have a JFileChooser that has multiple selections enabled. The selections are made by clicking on one file, holding the shift key down, and clicking another file. Is there a way to select multiple files using only the mouse (not the shift key), by holding down the mouse button and dragging?
0
Comment
Question by:allelopath
6 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 24758566
The only way I know of is the shift or ctrl + click to highlight a number of files beginning with the first you select and through the next you select with shift held down.  Holding ctrl allowing you to pick individual files at random.
0
 
LVL 92

Expert Comment

by:objects
ID: 24758576
afaik there isn't sorry
0
 
LVL 2

Assisted Solution

by:sirtam
sirtam earned 200 total points
ID: 24761813
As you see from the API, when marking and selecting files it will only return ONE objectt.
If you want a more strong file chooser you will either have to make it yourself or use one of the premade ones available though google.

Remember: JFileChooser is a SIMPLE mechanism.

Java 6 api - JFileChooser:
http://java.sun.com/javase/6/docs/api/javax/swing/JFileChooser.html
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 1

Author Comment

by:allelopath
ID: 24763406
>>it will only return ONE object.
If that one object contains multiple files, no matter how selected, then all is well

>>use one of the premade ones available though google.
I'm not following you here. Google has an API with JFileChoosers?
0
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 300 total points
ID: 24763781
Simple answer is that JFileChooser doesn't do this at all as far as I know, so answer is NO to your question.
If the thought is to be able to select multiple files using just the mouse, you can take a look at other API's/implementations that may help which is what sirtam may have been eluding too.

One approach is to implement something like this example which allows you to make selections through check boxes.  Since you can check a box with mouse only, would get you to your goal.

http://www.java2s.com/Code/Java/Swing-JFC/FileSystemTree.htm
0
 
LVL 1

Author Comment

by:allelopath
ID: 24763841
mwvisa1:
I understand that the answer is NO, but I was confused by sirtam's response in that his point that it returns one object seemed irrelevant and that I don't know he meant by "available through google"

I'll take a look at the FileSystemTree.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question