• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JFileChooser (Open File Dialog)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to make a Open File (JFileChooser) dialog
non-resizable? By default, it's resizable.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic