Cant get the size of my JFrame磗 contentPane, returns 0.

I have a class which extends JFrame. I add a few things to it by using

this.getContentPane().add(someThing);

Right now I need to use absolute positioning so I use the NullLayout

this.getContentPane().setLayout(null);

Therefore I also need to know the sizes of the contentPane. I have tried

this.getContentPane().getSize().getHeight();

this.getContentPane().getHeight();

but both returns 0

[470 byte] By [sandsatera] at [2007-10-3 2:51:25]
# 1
That should only work when your frame is visible.
PhHeina at 2007-7-14 20:40:17 > top of Java-index,Desktop,Core GUI APIs...
# 2

> Right now I need to use absolute positioning so I use

> the NullLayout

> this.getContentPane().setLayout(null);

You are going to run into difficulty doing. I think you will find it much easier to use layout managers.

http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html

zadoka at 2007-7-14 20:40:17 > top of Java-index,Desktop,Core GUI APIs...
# 3
Yes, it worked fine now! Thankyou.It was when using a layout manager I run into difficulties. In this particular case I think it will work better. I might try again with a manager later but for now I have to focus on some other things.
sandsatera at 2007-7-14 20:40:17 > top of Java-index,Desktop,Core GUI APIs...