🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Zero values returned for getX( ), getY( ), getSize( ) and getLocation( ) - Why?

#9859
From: Jeff Marendo
Date: Wed, 12 Jan 2000 00:00
26 lines
1937 bytes
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
Technical Details
Message-ID: <85i9cb$5q27@bornews.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,10a4f12cdbe9765b,start
X-Google-Attributes: gid111d45,public
From: "Jeff Marendo" <marendoj@commos.com>
Subject: Zero values returned for getX( ), getY( ), getSize( ) and getLocation( ) - Why?
Date: 2000/01/12
Message-ID: <85i9cb$5q27@bornews.borland.com>
X-Deja-AN: 571684763
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Organization: CommTech Corporation
X-MSMail-Priority: Normal
Reply-To: "Jeff Marendo" <marendoj@commos.com>
Newsgroups: borland.public.jbuilder.java.swing