package interfaces;
import java.awt.Button;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
public class GridBagLayoutTest {
/**creamos una matris en la cual nosostros ubicamos la posicion
* de los botones dentro de ella.
* @param args
*/
public static void main(String[] args) {
Frame f=new Frame("GridBagLayoutTest");
f.setLayout(new GridBagLayout());
Button boton= new Button("Boton 1");
GridBagConstraints c=new GridBagConstraints();
c.fill=GridBagConstraints.HORIZONTAL;
c.weightx=0.5;
c.gridx=0;
c.gridy=0;
f.add(boton,c);
boton =new Button("Boton 2");
c.gridx=1;
c.gridy=0;
f.add(boton,c);
boton =new Button("Boton 3");
c.gridx=2;
c.gridy=0;
f.add(boton,c);
boton =new Button("boton 4");
c.ipady=40;
c.weightx=0.0;
c.gridwidth=3;
c.gridx=0;
c.gridy=1;
f.add(boton, c);
boton=new Button("Boton 5");
c.ipady=0;
c.weighty=1.0;
c.anchor=GridBagConstraints.PAGE_END;
c.insets=new Insets(10,0,0,0);
c.gridx=1;
c.gridy=2;
f.add(boton,c);
f.pack();
f.setVisible(true);
}
}
No hay comentarios:
Publicar un comentario