[5215] in java-interest

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

Re: GridBagLayout, and other layout problems.

daemon@ATHENA.MIT.EDU (Mete Senocak)
Fri Feb 2 05:21:13 1996

Date: Fri, 02 Feb 1996 00:21:12 -0800
From: Mete Senocak <msenocak@arachnid.microweb.com>
To: James Waldrop <sulam@construct.net>
Cc: java-interest@java.sun.com

Hi James:

James Waldrop wrote:
> 
> 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...
>

Here is one problem: You have to create a panel object first and then call its 
method setLayout(), like this:

Panel  yourPanel;
yourPanel = new Panel();
yourPanel.setLayout(new GridLayout());

I didn't check the rest of the code thoroughly, it might work though after fixing 
this problem. 

Let me know if it works.

Good luck,

-Mete
-
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