
*El uso de el GridBagLayout es colocar una ventana en donde situaremos algunos componentes en determinadas posiciones en este caso colocamos botones.
*El contenedor que se ha creado tiene una clase llamada "layout", que es la encargada de distribuir los botones dentro del contenedor.
Estas son algunas instrucciones utilizadas:
*DECLARACION DE LOS CONTENEDORES
GridBagLayout gridbag=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
setLayout(gridbag);
gbc.fill=GridBagConstraints.BOTH;
gbc.weightx=1.0;
*COLOCACION DE LOS ELEMENTOS EN LAS POSICIONES CORRESPONDIENTES
Button boton0=new Button("Boton 0");
gridbag.setConstraints(boton0,gbc);
add(boton0);
boton0.setBackground(Color.red);
gbc.gridwidth=1;
gbc.gridheight=2;
gbc.weighty=1.0;
No hay comentarios:
Publicar un comentario