Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextAera sizing issue ?

 
William Quantrill
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need a text box that is able to scroll (horizontal only). Ive placed a JTextArea next to a button. When i start entering text into the textarea and the scrollbars become visible, it covers my textarea. how can i adjust for this ?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What sort of layout are you using in the component that holds the text area?

What you might want to do is set JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS so you can account for the size of the scrollbar when initially laying out your components. The side effect is that there will be a scrollbar in your text area even when you don't really need one, but you won't have the problem you are having now.

Also, unless you absolutely need the actual scrollbar to scroll, you could just use a JTextField. You can enter Strings longer than the textfield and then scroll through them using the arrow keys when the textfield has focus.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic