Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add Vertical ScrollBar whenever text is exceded visible TextArea?

 
Pradeep Kumar Raju
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scrolling? That should be easy enough: look at this Java Tutorials page.
 
Pradeep Kumar Raju
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it but i want only vertical scrollbar & also it should be activated only if text is exceeded visible TextArea.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought you could specify which way those scroll panes scroll.
 
K. Tsang
Bartender
Posts: 3440
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JScrollPane API has setHorizontalScrollBarPolicy and setVeriticalScrollBarPolicy methods to do just that. The default is both horizontal and vertical "as needed"
 
Rob Camick
Ranch Hand
Posts: 2580
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all use "meaningful" variable names. Two character names are not meaningful.

i want only vertical scrollbar & also it should be activated only if text is exceeded visible TextArea.


That is the default behaviour when you add a JTextArea to a scrollpane.

I got it but


Post the code you used.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic