• Post Reply Bookmark Topic Watch Topic
  • New Topic

jtable and scrollpane

 
Marcus Hoe
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need help in 2 areas.
1. Have a JTextArea in a JScrollPane. How do I make it autoscroll when I append text to the JTextArea?
2. Have a JTable showing records pertaining to a vector. How do I get the current selection so that I can remove the selected row from the vector accordingly?
Thanks
 
Swamy Vatti
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
About the second question...
table.getSelectedRow(s) gives u the selected rows.
remove them from the underlying vector and repaint the table...
 
Prashanth menon
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
In the first one when I made a call to the method :
getLineCount() it went for autoscrolling. The return value is integer representing number of lines in the textarea.
regards
Prashanth
 
Marcus Hoe
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite sure how to apply getLineCount(). Actually, when I append text to JTextArea, I want the viewport to show the latest text input. Can anyone advise?
 
Prashanth menon
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dear Marcus
getLineCount() actually returns the total line count of the textarea. Usually when I append
a text the scroll bars go down to the bottom.
If that does not happen then I would suggest you to use
setCaretPosition(jta.getText().length())
jta is the JTextArea object.
regards
Prashanth
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!