Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2003

Tip: Looking for answers? Try searching our database.

not modal File Choosers ?

Thread view: 
Greg - 04 Nov 2003 11:01 GMT
Hi

How can I create not modal File Choosers dialog?
Best Regards
Signature

Greg

Thomas Weidenfeller - 04 Nov 2003 13:26 GMT
> How can I create not modal File Choosers dialog?

Use a normal JDialog. Add a JFileChooser to it like you would add any
other component to a JDialog (JFileChooser is a component). Subscribe
to ActionEvents from the JFileChooser component (addActionListener()).

Use the various set...() methods to set button text, mnemonics, title,
dialog type, etc. (See the API documentation).

Then call JFileChooser.rescanCurrentDirectory() on the JFileChooser,
followed by JDialog.setVisible(true) on the JDialog.

/Thomas
Babu Kalakrishnan - 04 Nov 2003 13:35 GMT
> How can I create not modal File Choosers dialog?

Call the createDialog method of the JFileChooser to first build the
dialog, set its properties (whether OpenDialog, SaveDialog etc) and call
setModal(false) on it before invoking its show() method.

BK
Thomas Weidenfeller - 04 Nov 2003 14:26 GMT
>> How can I create not modal File Choosers dialog?
>
> Call the createDialog method of the JFileChooser to first build the
> dialog,

createDialog() is protected (don't ask me why). He would have to
subclass. createDialog() also requires Java 1.4 or newer.

/Thomas
Babu Kalakrishnan - 04 Nov 2003 16:44 GMT
>>>How can I create not modal File Choosers dialog?
>>
[quoted text clipped - 3 lines]
> createDialog() is protected (don't ask me why). He would have to
> subclass. createDialog() also requires Java 1.4 or newer.

Ah.. Thanks for pointing it out, I hadn't noticed this.

Since the createDialog function had been present on earlier versions of
JDKs for the JOptionPane class (and was public), I assumed it would be
the same case with the JFileChooser as well and didn't bother to read
the fine print :-)

Sorry about the error.

BK
Thomas Weidenfeller - 05 Nov 2003 08:34 GMT
> Ah.. Thanks for pointing it out, I hadn't noticed this.

I just remembered it, because I got caught by it some time ago, too. I
really don't understand why this isn't a public method.

Maybe it would be a good idea for the Swing team to create some common
interface for all the convenience dialogs, so they all can be handled
the same way.

Anyway, maybe someone want's to jump through Sun's hoops and file a bug
report / feature request on this one :-)

/Thomas


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.