Vel Eous
asked on
remove horizontal scrolling from jscrollpane
How would I amend the following code so that it had no horizontal scrolling ?
getContentPane().add(new JScrollPane(jtextAreaDispl ay), BorderLayout.CENTER);
getContentPane().add(new JScrollPane(jtextAreaDispl
ASKER
I dont appear able to do that due to the way I have set up my scrollpane:
JTextArea jtextAreaDisplay = new JTextArea();
getContentPane().add(new JScrollPane(jtextAreaDispl ay), BorderLayout.CENTER);
JTextArea jtextAreaDisplay = new JTextArea();
getContentPane().add(new JScrollPane(jtextAreaDispl
You can also set these in the constructor, like so:
JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
So for you it would be:
getContentPane().add(new JScrollPane(jtextAreaDispl ay, JScrollPane.HORIZONTAL_SCR OLLBAR_AS_ NEEDED, JScrollPane.HORIZONTAL_SCR OLLBAR_NEV ER), BorderLayout.CENTER);
I don't know what is thought to be best practice, but I alway create a named instance for any component I use. When I don't, I always seem to run into trouble later.
JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
So for you it would be:
getContentPane().add(new JScrollPane(jtextAreaDispl
I don't know what is thought to be best practice, but I alway create a named instance for any component I use. When I don't, I always seem to run into trouble later.
Oops. That should be:
getContentPane().add(new JScrollPane(jtextAreaDispl ay, JScrollPane.VERTICAL_SCROL LBAR_AS_NE EDED, JScrollPane.HORIZONTAL_SCR OLLBAR_NEV ER), BorderLayout.CENTER);
getContentPane().add(new JScrollPane(jtextAreaDispl
ASKER
Hmmm, ok that compiles, but my text still disapears off the screen ... :/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yourScroller.setHorizontal
The options are:
* JScrollPane.HORIZONTAL_SCR
* JScrollPane.HORIZONTAL_SCR
* JScrollPane.HORIZONTAL_SCR
and the same is available for the vertical scroll bar.