Unable to make the JTextArea scrollable..!

前端 未结 3 1693
再見小時候
再見小時候 2021-01-24 15:32

Here is my code:

final JTextArea textArea = new JTextArea();
textArea.setFont(new Font(\"MS UI Gothic\", Font.PLAIN, 13));
textArea.setLineWrap(true);
textArea.s         


        
3条回答
  •  后悔当初
    2021-01-24 16:23

    Ok...I finally got it to work...I specified the same set bounds in the scroll pane instead of the text area.. Here is the code.!!! ^_^

            final JTextArea textArea = new JTextArea();
            textArea.setFont(new Font("MS UI Gothic", Font.PLAIN, 13));
            textArea.setLineWrap(true);
            //textArea.setBounds(77, 310, 474, 136);
    
            JScrollPane scroll = new JScrollPane (textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);         
            scroll.setBounds(77, 310, 474, 136);
            contentPane.add(scroll);
    

    Here are the screenshots:

    Previous: http://oi40.tinypic.com/11jyum0.jpg
    Now: http://oi44.tinypic.com/2s9vdvt.jpg

提交回复
热议问题