🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: JFrame Minimum Size

#8640
From: Paul Whittington
Date: Fri, 04 Aug 2000 00:00
51 lines
1973 bytes
After a search of www.javasoft.com, Duh!, I found the answer.  I
added the following listener to my JFrame.

  void this_componentResized(ComponentEvent e) {
    int width = getWidth();
    int height = getHeight();

    //Set width to minimums if necessary
    if ((width < 800) || (height < 600)) {
      if (width < 800) {
        width = 800;
      }
      if(height < 600) {
        height = 600;
      }
      setSize(width, height);

      //Center the window
      Dimension screenSize = 
        Toolkit.getDefaultToolkit().getScreenSize();
      Dimension frameSize = getSize();
      if (frameSize.height > screenSize.height) {
        frameSize.height = screenSize.height;
      }
      if (frameSize.width > screenSize.width) {
        frameSize.width = screenSize.width;
      }
      setLocation((screenSize.width-frameSize.width)/2, 
                  (screenSize.height-frameSize.height)/2);
    }
  }


Paul Whittington wrote:
> 
> Is there a way to set the miniumum size for a JFrame?
> 
> I have a Java application and I don't want to allow it to get
> smaller then the minium X and Y sizes I specify.
> 
> --
> Paul Whittington
> Chief Engineer
> GrepNet, Inc.
> paul@grep.net

-- 
Paul Whittington
Chief Engineer
GrepNet, Inc.
paul@grep.net
Technical Details
Message-ID: <398AEC27.40ADA3B9@grep.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <398A02E5.C216AC71@grep.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,689e953802321aab
X-Google-Attributes: gid111d45,public
X-Google-Thread: 10fd6d,689e953802321aab
X-Google-Attributes: gid10fd6d,public
From: Paul Whittington <paul@grep.net>
Subject: Re: JFrame Minimum Size
Date: 2000/08/04
Message-ID: <398AEC27.40ADA3B9@grep.net>
X-Deja-AN: 654470153
Content-Transfer-Encoding: 7bit
References: <398A02E5.C216AC71@grep.net>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: newsabuse@supernews.com
Organization: GrepNet, Inc.
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing,comp.lang.java.gui