Create a JTextArea with Scroll

1

I try to put Scroll in the following way:

private JPanel crearPanelFijo() {
    listado = new JTextArea(7,20);
    listado.setEditable(false);
    sp = new JScrollPane(listado);
    JPanel jPanelText = new JPanel();
    jPanelText.add(new JLabel("Lista:"));
    jPanelText.add(listado);
    jPanelText.add(sp);
    return jPanelText;
}

But I do not get the Scroll, just the normal JTextArea.

I would like to know what happened.

Thanks

    
asked by FranEET 12.01.2017 в 16:44
source

1 answer

0

Try adding the following parameters to the JScrollPane constructor:

JScrollPane scrollBar = new JScrollPane(panel,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

Depending on whether you want the vertical / horizontal scroll or the two to appear, you must add HORIZONTAL_SCROLLBAR_NEVER or HORIZONTAL_SCROLLBAR_ALWAYS

    
answered by 12.01.2017 в 16:50