GridBag Layout queries  
Author Message
V S Rawat





PostPosted: 2004-6-20 0:15:00 Top

java-programmer, GridBag Layout queries It might appear long, but I think the answers will be of
just a few words describing the correct command/syntax.

After the Jbutton part has run successfully, the following
difficulties are coming in the next step.

- Individual buttons are not coming as same width. Whichever
button has more text or wider letters is coming wider, and
others are coming less wider.

- though left edge of a column of button is duly aligned,
the right edge is becoming zigzag due to the above.

- width of the largest button in a column is deciding the
width of the the entire column.

how to force all button to be of same width? If all buttons
in a column are of same width, the above are automatically
solved.

I am also finding that the three characters I have to
display are appearing in the centre, and there is huge space
left at the left and right of my text in the button.

Because of this, I have to unncessary keep my window wide so
that characters remain visible, otherwise several characters
are not becoming visible.

When I put setmargin I got this compile error.
setMargin(java.awt.Insets) in javax.swing.AbstractButton
cannot be applied to (int,int,int,int)
button[gridY1][gridX1].setMargin(0,0,0,0);

The best method would have been if we could have just given
a single width for all buttons, and it would have compressed
whatever text within that width.

- Even after giving gridwidth as 2 or 3, though the button
is reserving the width of those many columns, its width is
still that of a single button. the area next to it is coming
blank.

how to make it wider to fill the columns it is covering.

- Even after giving gridheight as 2, though the button is
reserving the height of those many rows, its height is still
of a single button. the area below it is coming blank.

how to make it taller to fill the rows it is covering.

ipadx or ipadx are not working. while trying to use
gridBagL.setConstraints(button, gridBagC);
it is giving error
setConstraints(java.awt.Component,java.awt.GridBagConstraints)
in java.awt.GridBagLayout cannot be applied to
(javax.swing.JButton[][],java.awt.GridBagConstraints)

what is the default height and width of a button?

in place of using an icon in setrolloverenabled(), can we
have some way to make it display whatever text is there in
the button, in a larger font size?

to set the horizontal alignment, if I am giving
button[gridY1][gridX1].setHorizontalAlignment(0);

it is still appearing at the centre. what are the options
for (int) are not shown in the tutorial.

Thanks.
-Rawat

 
V S Rawat





PostPosted: 2004-6-20 10:55:00 Top

java-programmer >> GridBag Layout queries several things have been solved. the remaining ones are:

but first, one new problem:
-The new window is opening in front of my parent window,
thus covering it. this being a big window is not leaving
much space for parent window.

How to bring parent window to front by default or by
clicking on parent, or by mouseover etc. this child window
can come up when clicked or again, by mouseover.

--------------
> - width of the largest button in a column is deciding the
> width of the the entire column.
>
> how to force a button to be of same specific width?
>
> The best method would have been if we could have just
> given a single width for all buttons, and it would have
> compressed whatever text within that width.

the tutorial says that for a button
width = width of text + 2*ipadx
height = height of text + 2*ipady

how to find width and height of text, or of letters in the text?

I need to work on the height and width o entire window.

--------------------
> in place of using an icon in setrolloverenabled(), can we
> have some way to make it display whatever text is there
> in the button, in a larger font size?
>
> to set the horizontal alignment, if I am giving
> button[gridY1][gridX1].setHorizontalAlignment(0);

what options can be given in the above in place of zero. it
is giving compile error for any negative/ positive/ alpha
value other than zero.

-Rawat