1

I have a class extending JFrame and a JTextArea with the configuration below. For some reason my Scroll doesn not appear. I can't figure out why.

     JTextArea ta=new JTextArea();
         ...

            ta.setText(out);
            JScrollPane scrollFrame = new JScrollPane(ta);
            //ta.setAutoscrolls(true);
            scrollFrame.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            scrollFrame.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            add(scrollFrame);
            add(ta);
            setSize(300, 300);
            setResizable(false);
            setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
            setVisible(true);

For example, Adding a Scrollable JTextArea (Java)

Community
  • 1
  • 1
Lorena Sfăt
  • 215
  • 2
  • 7
  • 18

1 Answers1

2

just add the scrollframe and not the JTextArea

 add(scrollFrame);
// add(ta);
JRowan
  • 6,824
  • 8
  • 40
  • 59