Article View: borland.public.jbuilder.java.swing
Article #9860Re: Zero values returned for getX( ), getY( ), getSize( ) and getLocation( ) - Why?
From: rwilkman
Date: Wed, 12 Jan 2000 00:00
Date: Wed, 12 Jan 2000 00:00
43 lines
2319 bytes
2319 bytes
Jeff: I believe most components don't exist "enough" to have this information until they are initialized/displayed. -Rich Jeff Marendo wrote: > > Hello, > > I'm having a problem and am asking for possible clarification. I have a > class within a project file in JBuilder3. This class inherits from JPanel > and it has some nested JPanels within it that contain basic components like > JTextField, JLabel, JButton, etc. The layout managers being applied to the > JPanels are either BorderLayout or XYLayout. > > I need to get the X and Y locations of various components (in relation to > where they are in their appropriate container) when an object of my class > first becomes instantiated. I also need their sizes. I've been trying to > call JComponent functions getX( ), getY( ), getSize( ), and getLocation( ) > from within jbInit( ) to get the values for any particular component, but I > keep getting return values of 0. Is this b/c jbInit( ) hasn't finished > executing or hasn't exited yet? > > If I initialize a component using setBounds(...) in jbInit then I get > non-zero values returned to me. If I add an actionListener to a button and > then call getX( ), etc. from within the function related to the > actionPerformed event of that button, I get non-zero values returned to me. > > So, the bottom line is I only get 0 values returned to me if I call the > functions mentioned above straight from jbInit( ), and I'm wondering why > that is. If anyone knows why, please clue me in. Thanks! > > Jeff -- ===== Rich Wilkman Senior Quality Assurance Engineer JBuilder Team If you are reading this from a newsgroup post, don't send mail.
Technical Details
Message-ID:
<387CBBCA.1EEF34EC@inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<85i9cb$5q27@bornews.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,10a4f12cdbe9765b X-Google-Attributes: gid111d45,public From: rwilkman <rwilkman@inprise.com> Subject: Re: Zero values returned for getX( ), getY( ), getSize( ) and getLocation( ) - Why? Date: 2000/01/12 Message-ID: <387CBBCA.1EEF34EC@inprise.com> X-Deja-AN: 571713704 Content-Transfer-Encoding: 7bit References: <85i9cb$5q27@bornews.borland.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing