Problem with extending JPanel

Posted by Halo on Stack Overflow See other posts from Stack Overflow or by Halo
Published on 2010-04-07T12:40:27Z Indexed on 2010/04/07 12:43 UTC
Read the original article Hit count: 263

Filed under:
|

I have an abstract entity:

public abstract class Entity extends JPanel implements FocusListener

And I have a TextEntity:

public class TextEntity extends Entity

Inside TextEntity's constructor I want to put a JTextArea that will cover the panel:

textArea = new JTextArea();
textArea.setSize(getWidth(),getHeight());
add(textArea);

But getWidth() and getHeight() returns 0. Is it a problem with the inheritance or the constructor?

© Stack Overflow or respective owner

Related posts about java

Related posts about inheritance