This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Is there a way to invoke caretUpdate()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Is there a way to invoke caretUpdate()?" Watch "Is there a way to invoke caretUpdate()?" New topic
Author

Is there a way to invoke caretUpdate()?

Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

I was building a simple text editor.
The code below is to initialize text component which extends JTextPane:


Now, I have JTabbedPane and every tab contains above component. I use CaretEvent to refresh label on status bar that displays current line/column number.
I also added ChangeListener to tabbedPane and implemented stateChanged() method. Is there any way to invoke caretUpdate() every time I select different tab, so above mentioned label is automatically refreshed?


The quieter you are, the more you are able to hear.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

I would have a separate method that is called both from caretUpdate and stateChanged.


luck, db
There are no new questions, but there may be new answers.
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

You're right, I don't know how I missed that!
Anyway, now the code should look something like this:



Now these methods can be invoked from stateChanged(), too, which is what I needed!

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there a way to invoke caretUpdate()?
 
Similar Threads
setEditable and blinking cursor
Displaying line # with JTextArea
Columns vs letters
TextArea and events
Multiple files?