• Post Reply Bookmark Topic Watch Topic
  • New Topic

selecting row in JTextPane

 
madhu Chitloore
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was trying out one simple example where i have one JTextPane which have multiple lines and one JButton. upon clicking button(Next) i want to select a row, on succeeding clicks i need to select next rows..... i tried below logic but did not work ...


if you have any idea like how to select a row on clicking a button next please tell me.

Thanks,
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Madhu,
Just a suggestion and I haven't tried it myself.
Try using a one column JTable with no gridlines or a JList.

Good Luck,
Avi.
 
madhu Chitloore
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply , but my experiment on jtextpane. how to get a row in jtextpane ? and how to traverse next row ?
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to search for the next line break character, then change the selection. If no line break character is found select until the end.
 
madhu Chitloore
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understood your point , then how to check line break character ?? is it possible?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Madhu,
Following code will return the line break character:

Good Luck,
Avi.
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And using getText().indexOf you can find the location of the next, previous and all other line breaks.
 
Darryl Burke
Bartender
Posts: 5152
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just another cross poster. And the question is already marked as answered on the Sun forum.
http://forums.sun.com/thread.jspa?threadID=5348252
 
Campbell Ritchie
Marshal
Posts: 52519
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Darryl Burke; you ought at least to point out to people on both fora that you are posting twice. Please read this FAQ.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!