This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextPane  RSS feed

 
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???
 
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!!!
 
"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 ]
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!