• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextPane  RSS feed

 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I do to discover the current position of the cursor in a textpane??? for example if the user keeps surfing on the text. Is there a way to discover the position of the cursor on the text in a jtextpane???
 
John Dale
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By cursor, you may mean what Swing calls the caret. Check out getCaret() and getCaretPostion() on the javax.swing.text.JTextComponent class, and also the javax.swing.textCaret class.
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes!!! that 's it!!! thanks a lot!!!
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gee John! - you think that you made him happy?
Such enthusiasm!
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there a way to block the jtextpane??? for example if I don't want the user writing porn words in my textpane!is there an easy way to do that???
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would need to write yourself a little parser to scan through the input and look for specific words/patterns.
You could use Regular Expressions to do this.
Once you identify such a pattern you can edit it out.
[ December 19, 2002: Message edited by: Cindy Glass ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!