style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-5164839828746352"
data-ad-slot="7563230308">

Como agregar un JScrollPane a un JContentPane

1.-Como añadir un JList a un scrollpane.
2.-Añadir scrollpane a un contenpane <=== aquí es donde estoy bloqueado.

Pongo mi codigo a ver si me dan una mano

package manager.empaque.view;

import javax.swing.JPanel;
import javax.swing.JDialog;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import manager.empaque.model.EmpleadoModel;
import java.awt.Point;
import java.awt.Font;
import javax.swing.JList;
import javax.swing.JComboBox;
import javax.swing.JCheckBox;

public class FrmEmpleado extends JDialog {

private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JTextField jTNombre = null;
private JLabel jLabel = null;
private JButton jBEliminar = null;
private JButton jBGuardar = null;
private JButton jBCancelar = null;
private JButton jBAgregar = null;
private JButton jBEditar = null;
private JButton jBCerrar = null;
private JTextField jTCodigo = null;
private JLabel jLabel3 = null;
private JComboBox jComboBox = null;
private JCheckBox jCheckBox = null;
private JCheckBox jCheckBox1 = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel4 = null;
private JButton jButton = null;
private JButton jButton1 = null;
private JLabel jLabel5 = null;
private JLabel jLabel6 = null;
private JLabel jLabel7 = null;

/**
* @param owner
*/
public FrmEmpleado(java.awt.Frame parent, boolean modal) {
super(parent,true);
initialize();
enabledDisabled(false);
}

/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(624, 520);
this.setContentPane(getJContentPane());

}

/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel7 = new JLabel();
jLabel7.setText("Puesto:");
jLabel7.setBounds(new Rectangle(255, 120, 120, 26));
jLabel6 = new JLabel();
jLabel6.setText("Salario de Empleado");
jLabel6.setBounds(new Rectangle(469, 215, 128, 22));
jLabel5 = new JLabel();
jLabel5.setText("Catalogo de Salarios");
jLabel5.setBounds(new Rectangle(254, 214, 138, 24));
jLabel4 = new JLabel();
jLabel4.setText("Tipo de Pago:");
jLabel4.setBounds(new Rectangle(254, 168, 120, 29));
jLabel2 = new JLabel();
jLabel2.setText("Gastos y pagos");
jLabel2.setBounds(new Rectangle(434, 186, 139, 21));
jLabel1 = new JLabel();
jLabel1.setText("Lista de raya");
jLabel1.setBounds(new Rectangle(434, 152, 139, 21));
jLabel3 = new JLabel();
jLabel3.setFont(new Font("Dialog", Font.BOLD, 24));
jLabel3.setBounds(new Rectangle(134, 12, 313, 45));
jLabel3.setText("Catalago de empleados");
jLabel = new JLabel();
jLabel.setText("Nombre:");
jLabel.setBounds(new Rectangle(255, 74, 123, 24));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJTNombre(), null);
jContentPane.add(jLabel, null);
jContentPane.add(getJBEliminar(), null);
jContentPane.add(getJBGuardar(), null);
jContentPane.add(getJBCancelar(), null);
jContentPane.add(getJBAgregar(), null);
jContentPane.add(getJBEditar(), null);
jContentPane.add(getJBCerrar(), null);
jContentPane.add(getJTCodigo(), null);
jContentPane.add(jLabel3, null);
jContentPane.add(getJComboBox(), null);
jContentPane.add(getJCheckBox(), null);
jContentPane.add(getJCheckBox1(), null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(jLabel4, null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(jLabel5, null);
jContentPane.add(jLabel6, null);
jContentPane.add(jLabel7, null);
//Intento añadir el scrollPane al contenPane
jContentPane.add(jScrollPane,null);
}
return jContentPane;
}

/**
* This method initializes jTNombre
*
* @return javax.swing.JTextField
*/
private JTextField getJTNombre() {
if (jTNombre == null) {
jTNombre = new JTextField();
jTNombre.setBounds(new Rectangle(390, 74, 185, 25));
}
return jTNombre;
}

/**
* This method initializes jBEliminar
*
* @return javax.swing.JButton
*/

private JButton getJBEliminar() {
if (jBEliminar == null) {
jBEliminar = new JButton();
jBEliminar.setText("Eliminar");
jBEliminar.setBounds(new Rectangle(245, 396, 90, 35));
jBEliminar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {

}
});
}
return jBEliminar;
}

/**
* This method initializes jBGuardar
*
* @return javax.swing.JButton
*/
private JButton getJBGuardar() {
if (jBGuardar == null) {
jBGuardar = new JButton();
jBGuardar.setText("Guardar");
jBGuardar.setBounds(new Rectangle(375, 396, 90, 35));
jBGuardar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {

}
});
}
return jBGuardar;
}

/**
* This method initializes jBCancelar
*
* @return javax.swing.JButton
*/
private JButton getJBCancelar() {
if (jBCancelar == null) {
jBCancelar = new JButton();
jBCancelar.setText("Cancelar");
jBCancelar.setBounds(new Rectangle(505, 396, 90, 35));
jBCancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
enabledDisabled(false);

}
});
}
return jBCancelar;
}

/**
* This method initializes jBAgregar
*
* @return javax.swing.JButton
*/
private JButton getJBAgregar() {
if (jBAgregar == null) {
jBAgregar = new JButton();
jBAgregar.setText("Agregar");
jBAgregar.setBounds(new Rectangle(245, 440, 90, 35));
jBAgregar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
enabledDisabled(true);
cleanJTextField();
getJTCodigo().setText("0");
}
});
}
return jBAgregar;
}

/**
* This method initializes jBEditar
*
* @return javax.swing.JButton
*/
private JButton getJBEditar() {
if (jBEditar == null) {
jBEditar = new JButton();
jBEditar.setText("Editar");
jBEditar.setBounds(new Rectangle(375, 440, 90, 35));
jBEditar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
int codigo = Integer.parseInt(getJTCodigo().getText());
if (codigo>0){
enabledDisabled(true);
}else{
JOptionPane.showMessageDialog(null, "Selecciona registro para modificar\n");
}
}
});
}
return jBEditar;
}

/**
* This method initializes jBCerrar
*
* @return javax.swing.JButton
*/

private JButton getJBCerrar() {
if (jBCerrar == null) {
jBCerrar = new JButton();
jBCerrar.setText("Cerrar");
jBCerrar.setBounds(new Rectangle(505, 440, 90, 35));
jBCerrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
dispose();
}
});
}
return jBCerrar;
}

/**
* This method initializes jTCodigo
*
* @return javax.swing.JTextField
*/
private JTextField getJTCodigo() {
if (jTCodigo == null) {
jTCodigo = new JTextField();
jTCodigo.setText("0");
jTCodigo.setBounds(new Rectangle(555, 14, 35, 32));
jTCodigo.setVisible(true);
}
return jTCodigo;
}

private void enabledDisabled(boolean isParam){
getJTNombre().setEnabled(isParam);

getJBEliminar().setVisible(isParam);
getJBGuardar().setVisible(isParam);
getJBCancelar().setVisible(isParam);

getJBAgregar().setVisible(!isParam);
getJBEditar().setVisible(!isParam);
getJBCerrar().setVisible(!isParam);
}

private void cleanJTextField(){
getJTNombre().setText("");

}

/**
* This method initializes jList
*
* @return javax.swing.JList
*/

/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox() {
if (jComboBox == null) {
jComboBox = new JComboBox();
jComboBox.setBounds(new Rectangle(388, 119, 185, 25));
}
return jComboBox;
}

/**
* This method initializes jCheckBox
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox() {
if (jCheckBox == null) {
jCheckBox = new JCheckBox();
jCheckBox.setBounds(new Rectangle(390, 150, 23, 23));
}
return jCheckBox;
}

/**
* This method initializes jCheckBox1
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox1() {
if (jCheckBox1 == null) {
jCheckBox1 = new JCheckBox();
jCheckBox1.setBounds(new Rectangle(390, 187, 23, 23));
}
return jCheckBox1;
}

/**
* This method initializes jList2
*
* @return javax.swing.JList
*/

/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setText(">");
jButton.setBounds(new Rectangle(405, 273, 52, 26));
}
return jButton;
}

/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setText("<");
jButton1.setBounds(new Rectangle(406, 330, 47, 26));
}
return jButton1;
}

//Creo el JList
JList jList = new JList();
//Creo scrollPane y le añado el jList
JScrollPane jScrollPane = new JScrollPane(jList);

} // @jve:decl-index=0:visual-constraint="10,10"

Opciones de visualización de comentarios

Seleccione la forma que prefiera para mostrar los comentarios y haga clic en «Guardar las opciones» para activar los cambios.

Solucionado Hilo Cerrado

Voy a listar los pasos para el IDE eclipse ya que uso el Visual Editor para añadir controles a mis formularios:

1.-Primero ir a contenedores y añadir el JScrollPane
2.-Añadir el Jlist dentro del JScrollPane

Así lo solucione y pues ya mire el código como lo hace gracias.

style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-5164839828746352"
data-ad-slot="7563230308">