Article View: borland.public.jbuilder.java.swing
Article #10826Re: How can we get the client frame's size? (emergency)
From: Johan Forsberg
Date: Fri, 06 Aug 1999 00:00
Date: Fri, 06 Aug 1999 00:00
27 lines
1694 bytes
1694 bytes
Eric Maziade <maze@novisoft.com.nospam> skrev i
diskussionsgruppsmeddelandet:7oenap$em3@forums.borland.com...
> My app need to pop a new frame with an image in it (much like an image
> viewer), therefore I need to set the fame's size to the image's size.
> The problem is that with the header and borders of the frame, the image
wont
> fit, so I need to compensate so the client size of the frame (and not the
> frame's size) be the size of the image.
>
> I have yet to find how to get the client size (and therefore being able to
> get the non-client space taken).
>
> Can anyone help me?
I have had a similar problem... My solution was to create a dummy frame,
containing a single component of known size. Then I packed it:
JFrame tmpFrame=new JFrame();
JPanel tmpPanel=new JPanel();
tmpPanel.setPreferredSize(new Dimension(100,100));
tmpFrame.getContentPane().add(tmpPanel, BorderLayout.CENTER);
tmpFrame.pack();
int borderWidth=tmpFrame.getBounds().width-100;
int borderHeight=tmpFrame.getBounds().height-100;
Note that you don't even have to show the temporary frame.
Technical Details
Message-ID:
<7oep9v$dj6@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7oenap$em3@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,c42efb1180c7810d X-Google-Attributes: gid111d45,public From: "Johan Forsberg" <jfo@SPAM_SPAM_EGGS_SPAMstmf.se> Subject: Re: How can we get the client frame's size? (emergency) Date: 1999/08/06 Message-ID: <7oep9v$dj6@forums.borland.com> X-Deja-AN: 509589197 References: <7oenap$em3@forums.borland.com> Organization: Another Netscape Collabra Server User X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Newsgroups: borland.public.jbuilder.java.swing