java bean init component?

P

Peter

Hi
I am writting a Java Bean which extends JPanel, inside the jpanel,
it contains many other component , such as jbutton, jtable.

In the constructor of this Java Bean, the getSize() of those
components give me 0,0, So where should i put the init code in?

i tried : hierarchyChanged(), propertyChanged(), vetoableChange(),
focusGain(), componentAdded(), componentShown() event, but still give
me 0,0

thanks
from Peter ([email protected])
 
J

John C. Bollinger

Peter said:
I am writting a Java Bean which extends JPanel, inside the jpanel,
it contains many other component , such as jbutton, jtable.

It is rarely appropriate to subclass JPanel. It is usually better to
use a standard JPanel and create a method in your application to
populate it appropriately. As another poster has noted, you should
normally use an appropriate LayoutManager to arrange the JPanel's
contents; when that is done it is very uncommon for the application code
to need the size of the contained components.
In the constructor of this Java Bean, the getSize() of those
components give me 0,0, So where should i put the init code in?

i tried : hierarchyChanged(), propertyChanged(), vetoableChange(),
focusGain(), componentAdded(), componentShown() event, but still give
me 0,0

The contained components don't have a size until their container is laid
out. You can accomplish that with pack().


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top