[5128] in java-interest

home help back first fref pref prev next nref lref last post

GridBagLayout, and other layout problems.

daemon@ATHENA.MIT.EDU (James Waldrop)
Mon Jan 29 20:34:57 1996

To: java-interest@java.sun.com
Date: Mon, 29 Jan 1996 16:06:32 -0800
From: James Waldrop <sulam@construct.net>


Ok, I can't wait for a decent Layout manager tutorial.  I'm trying to
use GridBagLayout, and having quite a few problems.

The general thing I want to see is:
 _______________________________
|                               |
|              A                |
|_______________________________|
 _______________________________
|                               |
|              B                |
|_______________________________|
 _______________________________
|______________C________________|

Where:

A: is a subclass of Panel which contains a subclass of Canvas that an
   image is drawn onto.

B: is a Panel which contains a TextArea.

C: is a Panel which contains a TextField.


Here's my code so far, please note the comments:

    public void init() {

        GridBagLayout gridBag = new GridBagLayout();
        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.BOTH;

//	setLayout(new FlowLayout());	  // default, doesn't show A ??
//      setLayout(gridBag);		  // I can't make it show component A
//      setLayout(new BorderLayout());    // Also doesn't show component A
        setLayout(new GridLayout(3, 0));  // This works, but isn't what I want
                                          // C is much too large...

        c.gridwidth = GridBagConstraints.REMAINDER;
        topPanel = new ImagePanel(this);
        gridBag.setConstraints(topPanel, c);
        add(topPanel);
//        add("North", topPanel);	  // Nope, it doesn't show up.

        Panel midPanel = new Panel();
        gridBag.setConstraints(midPanel, c);
        add(midPanel);

        outputArea = new TextArea(14,80);
        midPanel.add(outputArea);

        Panel bottomPanel = new Panel();
        gridBag.setConstraints(bottomPanel, c);
        add(bottomPanel);

        inputArea = new TextField(80);
        bottomPanel.add(inputArea);
}


I've tried explicitly setting gridx and gridy, played with weight, and
of course used gridheight and gridwidth, all to no effect.

Any advice?

James

--
James Waldrop                        /          Technical Director
sulam@construct.net              /              Construct Internet Design
sulam@well.com               /                  http://www.construct.net
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post