El código deja posicionado de esta manera al JList:
Y lo que yo deseo es esto:
Código:
Muchas gracias desde ya!!! 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);