>>>>> Kevin White writes:

    Kevin> I have a frame in which I would like to use no layout
    Kevin> manager so that I can directly position elements where I
    Kevin> want them.

    Kevin> I use the following code, in the constructor of a class
    Kevin> that descends from Frame:

    Kevin> setSize(600,380);
    Kevin> setLayout(null);
    Kevin> Label label=new Label("Hi there");
    Kevin> label.setBounds(10,10,200,20);
    Kevin> add(label);

    Kevin> Is there anything wrong with this?  This is what I do on
    Kevin> other platforms and works fine.  However, unless I use a
    Kevin> layout manager, I cannot see this label show up on the
    Kevin> window.

Your code will fail on other platforms too, e.g. Solaris.

The label is behind the Frame's title bar. When you don't use
a layout manager you have to take care of insets yourself. Unfortunately
Frame.getInsets() returns false values until the frame has been mapped
for the first time.

When the frame is already visible the following code should work:

Insets insets = getInsets();
label.setBounds(10 + insets.left, 10 + insets.top, 200, 20);


        Juergen


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to