Solved

JFileChooser - multiple selections with mouse

Posted on 2009-07-01
6
1,279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 60

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 60

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
jdbc error in jsp application 20 88
null output 3 58
IntelliJ and Eclipse Neon 2 installations 4 65
Selenium findElement(By.classname  identifier 15 32
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

737 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