Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Monday, November 19, 2007

define java GridBagLayout

gbag = new GridBagLayout(); Creates GridBagLayout.

Must add with GridBagConstraints object (gbc below). Can (carefully) reuse same gbc object.
gbc = new GridBagConstraints(); Creates a new GridBagConsraints object.
gbc.gridx = i; Column, counting from 0. Always start at 0. Don't use default (RELATIVE).
gbc.gridy = i; Column, counting from 0. Always start at 0. Don't use default (RELATIVE)..
gbc.gridwidth = i; Number of columns wide (default 1).
gbc.gridheight = i; Number of rows high (default 1).
gbc.weightx = d; Relative horizontal space to allocate if container expands. Default 0.0.
gbc.weighty = d; Relative vertical space to allocate if container expands. Default 0.0.
gbc.fill = fill; How to expand comp if space larger than preferred size. fill can be GridBagConstraints.NONE, GridBagConstraints.VERTICAL, GridBagConstraints.HORIZONTAL, GridBagConstraints.BOTH.
gbc.anchor = anch; If component doesn't fill the space, tells how it should be aligned. anch can be one of these GridBagConstraints constants: CENTER (default), NORTH, SOUTH, NORTHEAST, SOUTHWEST, EAST, WEST, SOUTHEAST, NORTHWEST
gbc.insets = ins; Space around component. Eg, gbc.insets = new Insets(10,5,5,10);
gbc.ipadx = i; Horizontal padding internal to component. Can be negative!
gbc.ipady = i; Vertical padding internal to component. Can be negative!

No comments:

Post a Comment

Archives