How do we remove vertical scroll bar of a jTextArea?
Remove vertical scroll of jTextArea
Collapse
X
-
Tags: None
-
-
Code:jTextArea2.setText("House No = "+house+","+add); //which almost comes upto 3 lines jTextArea2.setLineWrap(true); jTextArea2.setWrapStyleWord(true); JScrollPane pane = new JScrollPane(jTextArea2, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
Comment
-
Must be something wrong with some code that you haven't posted because this doesn't show scroll bars
Code:import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.UIManager; public class Test extends JFrame { private JScrollPane jScrollPane; private JTextArea textArea; public Test() { initComponents(); } private void initComponents() { setSize(500, 500); StringBuilder text = new StringBuilder(); for (int i = 0; i < 100; i++) { text.append("Line number " + (i + 1)).append("\n"); } textArea = new JTextArea(text.toString()); jScrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); getContentPane().add(jScrollPane); } public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // Turn off metal's use of bold fonts UIManager.put("swing.boldMetal", Boolean.FALSE); new Test().setVisible(true); } }); } }
Comment
Comment