I have created a JScrollbar (with a custom UI) and a JTextArea in a JScrollPane in a JPanel. I don't want to add the scrollbar as the scrollpane's horizontal scrollbar, because I want to be able to position it.
I tried setting the model on the scrollbar and adding it to the panel (see code), but this didn't work -- the thumb didn't size correctly (it always spanned the entire track) and wasn't positioned correctly.
JPanel panel = new JPanel();
JTextArea textArea = new JTextArea(col, rows);
JScrollPane scrollPane = new JScrollPane(textArea);
JScrollBar scrollBar = new JScrollBar();
scrollBar.setModel(scrollPane.getHorizontalScrollBar().getModel());
panel.add(textArea);
panel.add(scrollPane);
panel.add(scrollBar)
How can I link a scrollbar to my text area so the thumb sizes and behaves correctly and still be able to set the position and dimensions of my scrollbar?
Thanks!
textArea? Does it need to beJScrollBarin your panel (there isJSliderprobably more suited for this). - Xeon