Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #4998

Re: Using JFileChooser from modal dialog

From markspace <-@.>
Newsgroups comp.lang.java.gui
Subject Re: Using JFileChooser from modal dialog
Date 2012-02-09 23:07 -0800
Organization A noiseless patient Spider
Message-ID <jh2fnb$8nf$1@dont-email.me> (permalink)
References <02d2e4b3-ab8a-4063-82c9-bd6e991bfac7@lr19g2000pbb.googlegroups.com> <508f9a48-aa4e-46d0-ab0f-fcee1ae6e781@vh10g2000pbc.googlegroups.com>

Show all headers | View raw


On 2/9/2012 2:40 PM, Fred wrote:
> On Feb 9, 9:59 am, Fred<fred.l.kleinschm...@gmail.com>  wrote:
>> How do I pop up and use a JFileChooser from a modal dialog?


<http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html>

 From that page:

//Create a file chooser
final JFileChooser fc = new JFileChooser();
...
//In response to a button click:
int returnVal = fc.showOpenDialog(aComponent);


>>
>> I find the methods setModalExclusionType and setModalityType, but they
>> are methods of Window and Dialog; when I pop the file chooser using
>> showDialog(), how do I get access to the window or frame used to
>> display it so that I can set its modality?
>
> OK, gott it. Just pass the modal dialog (that is popping the
> FileChooser) to the showDialog() method instead of null


Hmm, not sure about that one.  According to that same web page:

"The argument to the showOpenDialog method specifies the parent 
component for the dialog. The parent component affects the position of 
the dialog and the frame that the dialog depends on."

Other stuff there too looks important.  I'm not sure how you should be 
manipulating the properties you mention, or why.



> (We are using
> a single FileChooser for the app, which can be popped up from any
> number of modal or non-modal dialogs)


Interestingly, this is correct.  I forget where I read this now, but the 
JFileChooser is designed to be used repeatedly.  It will save the users 
previous directory viewed, for example, so that the user doesn't have to 
click the browsing buttions to select the same directory each time the 
dialog box is viewed.


Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Using JFileChooser from modal dialog Fred <fred.l.kleinschmidt@gmail.com> - 2012-02-09 09:59 -0800
  Re: Using JFileChooser from modal dialog Fred <fred.l.kleinschmidt@gmail.com> - 2012-02-09 14:40 -0800
    Re: Using JFileChooser from modal dialog markspace <-@.> - 2012-02-09 23:07 -0800
  Re: Using JFileChooser from modal dialog gosmith666@gmail.com - 2013-09-10 12:26 -0700
    Re: Using JFileChooser from modal dialog "John B. Matthews" <nospam@nospam.invalid> - 2013-09-11 06:51 -0400

csiph-web