This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

automatic scrolling of JTextField

 
Anthony Yulo
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ei! How can I make a JTextField automatically scroll when my Text is longer than the width of my JTextField... Isn't this supposed to be automatic for the JTextField?
 
Candy Bortniker
Ranch Hand
Posts: 123
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to put the JTextField on a ScrollPane like this:
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
do you mean horizontal scrolling? I suppose so, as JTextField has only one row. what exactly do you mean by automatic? That the cursor (if any) is always visible, and the user can scroll by hitting the arrow left and right keys? that should work.
you can influence the initial placement of the text by either setting the horizontal alignment or placing the cursor (in the Document) explicitely, for what I remember.
Chantal
 
Steve Winer
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextArea does not automatic scrolling, so you have to extend it with your own class that does this. This is easy to do by adding a DocumentListener that sets the caret position to the end of the text when the document's content changes.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic