|
-
May 11th, 2000, 02:46 AM
#1
getSize() of a Container
I want to getSize() of a container, but I couldn't. The methods getSize().width and getSize().height below returned 0 and 0 which were incorrect. Even when I commented out both the button and add() method, they gave the same incorrect result. Any suggestions? Thanks in advance.
import java.awt.*;
import javax.swing.*;
public class ex2_1 extends JApplet
{
Container cont;
public void init()
{
cont = this.getContentPane();
cont.setLayout(new FlowLayout());
JButton bb = new JButton();
cont.add(bb);
System.out.println("width is "+cont.getSize().width+ "height is "+cont.getSize().height);
}
}
--------------------------------------------------------------------------------
-
May 11th, 2000, 09:35 AM
#2
Re: getSize() of a Container
just try
this.getSize() rather than
this.getContentPane().getSize()
Kannan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|