java.lang.Object
java.awt.GridBagLayout
- All Implemented Interfaces:
- LayoutManager, LayoutManager2, Serializable
- See Also:
- Top Examples, Source Code,
GridBagConstraints.weighty
, GridBagConstraints.weightx
, GridBagConstraints.anchor
, GridBagConstraints.insets
, GridBagConstraints.ipady
, GridBagConstraints.ipadx
, GridBagConstraints.fill
, GridBagConstraints.gridheight
, GridBagConstraints.gridwidth
, GridBagConstraints.gridy
, GridBagConstraints.gridx
, ComponentOrientation
public void addLayoutComponent(Component comp,
Object constraints)
- See Also:
- IllegalArgumentException, LayoutManager2
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void addLayoutComponent(String name,
Component comp)
- See Also:
- LayoutManager
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void AdjustForGravity(GridBagConstraints constraints,
Rectangle r)
- See Also:
adjustForGravity
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void ArrangeGrid(Container parent)
- See Also:
arrangeGrid
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public double[] columnWeights
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int[] columnWidths
- See Also:
getLayoutDimensions()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Hashtable<Component,GridBagConstraints> comptable
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected GridBagConstraints defaultConstraints
- See Also:
lookupConstraints(Component)
, setConstraints(Component, GridBagConstraints)
, getConstraints(Component)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public GridBagConstraints getConstraints(Component comp)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public float getLayoutAlignmentX(Container parent)
- See Also:
- LayoutManager2
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public float getLayoutAlignmentY(Container parent)
- See Also:
- LayoutManager2
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int[][] getLayoutDimensions()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected java.awt.GridBagLayoutInfo GetLayoutInfo(Container parent,
int sizeflag)
- See Also:
getLayoutInfo
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Point getLayoutOrigin()
- See Also:
ComponentOrientation
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public double[][] getLayoutWeights()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Dimension GetMinSize(Container parent,
java.awt.GridBagLayoutInfo info)
- See Also:
getMinSize
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public GridBagLayout()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1383]Create a frame using GridBagLayout
By Raja Muthusamy on 2005/04/07 07:42:48 Rate
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class MYFRAME
{
JFrame myFrame = new JFrame ( "Getting User Data" ) ;
Container cp = myFrame.getContentPane ( ) ;
} ;
class GridBagOne extends MYFRAME
{
JTextField name;
JLabel namelbl;
JTextField email;
JLabel emaillbl;
JTextArea address;
JLabel addresslbl;
JPasswordField password;
JLabel passwordlbl;
JLabel genderlbl;
JRadioButton malegender;
JRadioButton femalegender;
JLabel statelbl;
JComboBox state;
JButton ok;
JButton cancel;
JPanel pane = new JPanel ( new GridBagLayout ( ) ) ;
GridBagConstraints c = new GridBagConstraints ( ) ;
public void getDataDialog ( )
{
namelbl = new JLabel ( "Name:" ) ;
c.gridx = 0;
c.gridy = 0;
c.fill = c.BOTH;
pane.add ( namelbl, c ) ;
name = new JTextField ( 10 ) ;
c.gridx = 1;
c.gridy = 0;
pane.add ( name, c ) ;
genderlbl = new JLabel ( "Gender" ) ;
c.gridx = 0;
c.gridy = 1;
pane.add ( genderlbl, c ) ;
emaillbl = new JLabel ( "eMail:" ) ;
c.gridx = 0;
c.gridy = 2;
pane.add ( emaillbl, c ) ;
email = new JTextField ( 10 ) ;
c.gridx = 1;
c.gridy = 2;
pane.add ( email, c ) ;
passwordlbl = new JLabel ( "Password:" ) ;
c.gridx = 0;
c.gridy = 3;
pane.add ( passwordlbl, c ) ;
password = new JPasswordField ( 10 ) ;
password.setEchoChar ( '*' ) ;
c.gridx = 1;
c.gridy = 3;
pane.add ( password, c ) ;
addresslbl = new JLabel ( "Address:" ) ;
c.gridx = 0;
c.gridy = 4;
pane.add ( addresslbl, c ) ;
address = new JTextArea ( 2,10 ) ;
JScrollPane jsp = new JScrollPane ( address ) ;
c.gridx = 1;
c.gridy = 4;
pane.add ( jsp, c ) ;
statelbl = new JLabel ( "State" ) ;
c.gridx = 0;
c.gridy = 5;
pane.add ( statelbl, c ) ;
state = new JComboBox ( ) ;
String tn = "TamilNadu";
String ka = "Karnataka";
String an = "Andhra";
state.addItem ( tn ) ;
state.addItem ( ka ) ;
state.addItem ( an ) ;
c.gridx = 1;
c.gridy = 5;
pane.add ( state, c ) ;
ok = new JButton ( "OK" ) ;
c.gridx = 0;
c.gridy = 6;
c.fill = c.BOTH;
pane.add ( ok, c ) ;
cancel = new JButton ( "Cancel" ) ;
c.gridx = 1;
c.gridy = 6;
pane.add ( cancel, c ) ;
cp.add ( pane ) ;
myFrame.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE ) ;
myFrame.setSize ( 200,200 ) ;
myFrame.setVisible ( true ) ;
}
public static void main ( String [ ] args )
{
GridBagOne gb = new GridBagOne ( ) ;
gb.getDataDialog ( ) ;
}
}
public void invalidateLayout(Container target)
- See Also:
- LayoutManager2
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void layoutContainer(Container parent)
- See Also:
Container.doLayout()
, LayoutManager
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected java.awt.GridBagLayoutInfo layoutInfo
- See Also:
getLayoutInfo(Container, int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Point location(int x,
int y)
- See Also:
ComponentOrientation
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected GridBagConstraints lookupConstraints(Component comp)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected static final int MAXGRIDSIZE
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Dimension maximumLayoutSize(Container target)
- See Also:
preferredLayoutSize(Container)
, minimumLayoutSize(Container)
, LayoutManager2
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Dimension minimumLayoutSize(Container parent)
- See Also:
Container.doLayout()
, LayoutManager
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected static final int MINSIZE
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Dimension preferredLayoutSize(Container parent)
- See Also:
Container.getPreferredSize()
, LayoutManager
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected static final int PREFERREDSIZE
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void removeLayoutComponent(Component comp)
- See Also:
Container.removeAll()
, Container.remove(java.awt.Component)
, LayoutManager
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int[] rowHeights
- See Also:
getLayoutDimensions()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public double[] rowWeights
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setConstraints(Component comp,
GridBagConstraints constraints)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String toString()
- See Also:
- Object
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples