🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #8232

Re: JFileChooser size problem

#8232
From: John McGrath TeamB
Date: Thu, 05 Oct 2000 00:00
43 lines
1994 bytes
On Sun, 01 Oct 2000 19:23:57 -0500, Joi Ellis wrote:

> It looks like JFileChooser is forcing its initial size to
> 500x300 and to hell with what I'm telling it...!

It looks like you called that one right.  The following code is from 
MetalFileChooserUI.java:

    // Preferred and Minimum sizes for the dialog box
    private static int PREF_WIDTH = 500;
    private static int PREF_HEIGHT = 300;
    private static Dimension PREF_SIZE = new Dimension(
        PREF_WIDTH, PREF_HEIGHT);
       :
       :
    public Dimension getPreferredSize(JComponent c) {
        return PREF_SIZE;
    }

Other look-and-feels have different hard-coded sizes, but the size is 
hard coded in all of the standard look-and-feels.

This is pretty cheesy if you ask me.  I cannot think of any reason why 
the FileChooserUI implementations could not have sized the dialog based 
on a minimum size for the file list and the preferred size of the 
accessory.

The only way that I can think to deal with it, save writing your own UI 
delegate classes, is to set the preferred size for the JFileChooser.  But 
the size you will need will be different for different look-and-feels, so 
the best you can do is to select a different size depending on the name 
of the look-and-feel.

If I think of something better, I will let you know.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <MPG.1445eb857969656e989bd0@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <39D7D59D.176E4FA5@aravox.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,2f241fe4201eef13
X-Google-Attributes: gid111d45,public
From: John McGrath  [TeamB] <ng-b@JPMcGrath.net>
Subject: Re: JFileChooser size problem
Date: 2000/10/05
Message-ID: <MPG.1445eb857969656e989bd0@forums.borland.com>
X-Deja-AN: 677767567
References: <39D7D59D.176E4FA5@aravox.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing