Hi. I'm using Java Swing. I have a textarea in a panel. I don't need a horizontal scrollbar for that textArea, only a vertical scrollbar is needed. I disabled auto scrollbar options, but still the horizontal scrollbar is working. Please help me in thz.
+1
A:
ta.setLineWrap(true)
Sets the line-wrapping policy of the text area. If set to true the lines will be wrapped if they are too long to fit within the allocated width. If set to false, the lines will always be unwrapped
Wajdy Essam
2010-06-07 08:26:52
Its working..Thanks a lot Wajdy Essam..
charan
2010-06-07 08:48:08
A:
Two examples, the line wrap method and the scroll pane method:
public class Test {
public static void main(String[] args) {
// example text
String rep = "The quick brown fox jumps over the lazy dog.";
String all = rep;
for(int i = 0; i < 100; i++)
all += "\n" + rep;
// create the line wrap example
JTextArea first = new JTextArea(all);
first.setLineWrap(true);
// create the scroll pane example
JScrollPane second =
new JScrollPane(new JTextArea(all),
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
// lay it out
JFrame f = new JFrame("Test");
f.setLayout(new GridLayout(1,2));
f.add(first);
f.add(second);
f.setSize(400, 300);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
dacwe
2010-06-07 09:07:01