Вопрос

I can't figure out why this doesn't work... It hides the JTextArea.

JTextArea _area=new JTextArea();
_area.setBounds(10, 10, 465, 250);
add(_area);

JScrollPane scroller=new JScrollPane(_area);
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
add(scroller);
Это было полезно?

Решение

EDIT:

Shuffle the bound values set the bounds only of ScrollPane and not of TextArea.

        JTextArea _area = new JTextArea();
//        _area.setBounds(10, 10, 400, 250);
        add(_area);

        JScrollPane scroller = new JScrollPane(_area);
        scroller.setBounds(10, 10, 400, 250);
        scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        add(scroller);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top