You should consider using setPreferredSize instead of setSize for your
components. If you don't use swing, implement getPrefferedSize. Read
more about layout managers . They have the last word about the size of a
component. Either if you call setSize before or after adding a component
to a container, the size of the component is not completely determinate.
No wander you got different results on different platforms.
Here is an example with getPrefferedSize which will work on all platforms:
----------- Cut here -------------------
import java.awt.*;
import javax.swing.*;
public class TestFrame extends JFrame {
TestFrame() {
super();
JPanel c = new JPanel();
c.setPreferredSize(new Dimension(800, 600));
getContentPane().add(c); //default layout is BorderLayout
}
public static void main(String[] args) {
TestFrame tf = new TestFrame();
tf.pack();
tf.show();
}
}
----------- Cut here -------------------
-Iulian
Mona Wong wrote:
>Hi:
>
> Yesterday, I posted the following problem:
>
>
>> My GUI components do not show up when I first start up the program
>>on a
>>PC machine. I have to resize the window or do something to cause the
>>window to
>>repaint in order for them to show up. It works fine though on the Solaris
>>machine.
>>
>
> I've solved my problem and just wanted to post solution to the list in
>case someone goes looking through the list archives ...
>
> It turns out that I have setSize() *before* the getContentPane().add().
>When I move the setSize() to *after* the getContentPane().add(), the problem
>went away.
>
> Funny, this was only a problem for the PC and not the Solaris machines
>...
>
> My thanks to Dmitri for trying to help me debug the problem!!
>
>Cheers,
>
>Mona
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".