Visit my blog! http://jameshambrick.com
Visit my blog! http://jameshambrick.com
Originally posted by James Hambrick:
[QB]I am wanting to display what line and column that caret is on.
Visit my blog! http://jameshambrick.com
Visit my blog! http://jameshambrick.com
Note: The caretUpdate method is not guaranteed to be called in the event-dispatching thread. To use any methods inside of caretUpdate that update the GUI special handling is required to ensure they are executed on the event-dispatching thread. You can do this by wrapping the code inside a Runnable and calling SwingUtilities.invokeLater on that Runnable.
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Visit my blog! http://jameshambrick.com
Originally posted by Nicholas Jordan:
The only JTextArea implementing CaretListener is javax.swing.JTextArea.AccessibleJTextArea so (Brian Cole's posted code) may losing some needed information in the cast.
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Visit my blog! http://jameshambrick.com
Originally posted by Nicholas Jordan:
You have to reset your position values in the program directly in the interface listener methods, then set the values in the view from the updated varables in the data model. Using chained assignment operators is handy for this, but should not be overused.
Originally posted by Nicholas Jordan:
Note: The caretUpdate method is not guaranteed to be called in the event-dispatching thread. To use any methods inside of caretUpdate that update the GUI special handling is required to ensure they are executed on the event-dispatching thread. You can do this by wrapping the code inside a Runnable and calling SwingUtilities.invokeLater on that Runnable.
Visit my blog! http://jameshambrick.com
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Visit my blog! http://jameshambrick.com
Originally posted by Nicholas Jordan:
[Brian Cole:] No information is lost in the cast, whatever that means. And I don't see how the existence of any JTextAreas that happen to implement CaretListener is at all relevant.
What I had in mind (note I am working at the limit of my skills trying to help the poster) is that I do not see any getCaretPosition() or getCursorPosition() on class javax.swing.JComponent
... so to me that means where is the call getDot() coming from, and basically ditto your next point.
Let me put my frame of mind this way: " I have to see the code or I don't believe it. " and without intending to get a heavy computer science discussion underway, some code somewhere has to implement CaretListener.
My point was TextArea does not implement CaretListener, so where is the int pos = comp.getCaretPosition(); getting the int from if it is no longer a Caret ? I believe it is this line: Rectangle caretCoords = textPane.modelToView(dot); that does what I was driving at
[James Hambrick :] All I know is that after hitting the spacebar 65 or 66 times the cursor jumps down to the next line. The column count does not reset back to 1 and the line number does not increment by 1.
Yes, I undersand that it is doing something that is not what you have in mind: This work is not difficult, it is just that there is so much of it that more work gets done by osmosis than by a jump-up directed path. I find that it takes about five or ten readings of something to 'get the hang of it' and put up the things you will have to research so that I am not talking way over your head.
Originally posted by James Hambrick:
actually I dont understand any of this code here
Visit my blog! http://jameshambrick.com
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Visit my blog! http://jameshambrick.com
Visit my blog! http://jameshambrick.com
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Visit my blog! http://jameshambrick.com
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Originally posted by Nicholas Jordan:
Okay, that is the critical piece of information I was trying to elicit. I would maintian a line number and a position in a line as a nested class or as instance variable(s), then do the fixups when the view called the data model. Everyone ( it seems to me ) writes the View Model, then dismisses the Data Model with a studied, aristiocratic Air Superiority Complex that would leave the Amirejibi with a moderate case of heebie-jeebies. Brian Cole will be the one to help you if you want to have the View inform the Controller where the carrot is when the bunnies come to corrall your code.
Visit my blog! http://jameshambrick.com
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |