Article View: borland.public.jbuilder.java.swing
Article #10172Re: Get width of JPopupMenu
From: David Sykes
Date: Thu, 04 Nov 1999 00:00
Date: Thu, 04 Nov 1999 00:00
32 lines
1727 bytes
1727 bytes
Hi Paul, Thanks for your response. I will test it again, but if I remember correctly I already tried that with no effect. :-(. That would seem to me to be a little bit of a shortcoming in Swing, if I can't no the size of something before it is actually displayed! It makes placing this nicely on the screen a little difficult. Thanks, David Sykes edv consulting Paul Furbacher [TeamB] <pf@bilbo.bio.purdue.edu> wrote in message news:38211CDA.15EBE343@bilbo.bio.purdue.edu... > David Sykes wrote: > > > I have a JPopupMenu that I would like to place to the left of a given > > control. Unfortunately, all of the getSize(), getWidth(), getBounds() > > methods return a width of 0 before the menu is displayed. > > > > Does anybody know of a way to get the width of the popup _BEFORE_ it is > > displayed? > > I'm just guessing and don't have time to test this: JPopupMenu has > a public "pack()" method. Try doing that and then get the size. > Packing may force the "realization" of the component: until a > component has been realized and laid out, it doesn't have any > dimensions. > > > Paul Furbacher (TeamB)
Technical Details
Message-ID:
<7vrfs5$ps122@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7vbpgd$osv4@forums.borland.com> <38211CDA.15EBE343@bilbo.bio.purdue.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,49b67961a3be5cd1 X-Google-Attributes: gid111d45,public From: "David Sykes" <SykesD@bigfoot.com> Subject: Re: Get width of JPopupMenu Date: 1999/11/04 Message-ID: <7vrfs5$ps122@forums.borland.com> X-Deja-AN: 544301537 References: <7vbpgd$osv4@forums.borland.com> <38211CDA.15EBE343@bilbo.bio.purdue.edu> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.swing