Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/01/2016, 15:51
marixxaa
 
Fecha de Ingreso: enero-2016
Mensajes: 2
Antigüedad: 8 años, 3 meses
Puntos: 0
Problema con el gestor GridBagLayout

Hola! estoy intentando acomadar un JList en el marco, pero no tengo éxito, siempre queda en la misma posición, alguien me puede dar una ayuda? muchisimas gracias desde ya.

El código deja posicionado de esta manera al JList:




Y lo que yo deseo es esto:


Código:
String obrasSociales[] = { "Osde", "Osecac", "Galeno", "Swiss Medical"};
JList obraSocial =new JList(obrasSociales);
obraSocial.setVisibleRowCount(2);
ManejadorJList manejadorJList=new ManejadorJList();
obraSocial.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane scrollPane = new JScrollPane(obraSocial);
cuenta=new JTextField("",10);
nombre = new JTextField("",10);
apellido = new JTextField("",10);
dni = new JTextField("",10);
cuentaLabel = new JLabel("Cuenta");
nombreLabel = new JLabel("Nombre");
apellidoLabel = new JLabel("Apellido");
dniLabel = new JLabel("Dni");
ingresar= new JButton("Ingresar");
modificar= new JButton("Modificar");
vacio=new JLabel(" ");

GridBagLayout gbl=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
FlowLayout flowLayout1=new FlowLayout();
setLayout(gbl);




gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.WEST;
gbc.gridwidth=1;
gbc.insets=new Insets(0,0,0,0);
add(cuentaLabel, gbc);

gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.WEST;
gbc.insets=new Insets(0,0,0,0);
gbc.gridwidth = GridBagConstraints.REMAINDER;
add(cuenta, gbc);


gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.WEST;
gbc.gridwidth=1;
gbc.insets=new Insets(0,0,0,0);
add(nombreLabel, gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
add(nombre, gbc);

gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.WEST;
gbc.gridwidth=1;
gbc.insets=new Insets(0,0,0,0);
add(apellidoLabel, gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
add(apellido, gbc);

gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.WEST;
gbc.gridwidth=1;
gbc.insets=new Insets(0,0,0,0);
add(dniLabel, gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
add(dni, gbc);


gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.WEST;
gbc.gridwidth=1;
gbc.insets=new Insets(0,0,0,0);
add(ingresar, gbc);
gbc.fill=GridBagConstraints.NONE;
add(modificar,gbc);
Muchas gracias desde ya!!!