This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes JFileChooser (Open File Dialog) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFileChooser (Open File Dialog)" Watch "JFileChooser (Open File Dialog)" New topic
Author

JFileChooser (Open File Dialog)

Amit Nag
Greenhorn

Joined: May 04, 2002
Posts: 2
How to make a Open File (JFileChooser) dialog
non-resizable? By default, it's resizable.
Bill Liteplo
Ranch Hand

Joined: Oct 16, 2002
Posts: 88
Good question.
I would suggest looking in the Swing code for JFileChooser at the method createDialog. It creates a JDialog and puts the file chooser panel into it at BorderLayout.CENTER. When you call showOpenDialog this calls showDialog and, in turn, createDialog.
So, either take your JFileChooser and put it inside a JDialog that you create and control (possibly copying code from Swing), or create a class (or inner class or anonymous class) that extends JFileChooser and override the createDialog method so that it sets the JDialog to be non-resizable.
Use setResizable(false) from java.awt.Dialog on the JDialog.
For example, (this is copied from jdk1.4.1):

I haven't tried this code but my guess is it will work.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JFileChooser (Open File Dialog)