change blinker/cursor in a JTextArea
hey... I wat to change the... well, the cursor (the little blinking thing in a text area where subsequent typing appears) in a JTextArea. Not the pointer (the mouse icon showing where on the screen the mouse is cuz some ppl thought that was wat I meant) but the cursor in a JTextArea. Not sure if that last part changes the answer, but just in case, there it is!
Related Article: Implementing Action Listener and Change Listener
is a solved Java discussion thread by poojavb that has 2 replies, was last updated 7 months ago and has been tagged with the keywords: implementing, action, change, listener.
FALL3N
Junior Poster in Training
87 posts since May 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0
thank you for the prompt response, but unfortunately, that is not quite what I trying to do. I am not trying to change the position of the cursor, I am trying to change the appearance...
For instance, in the terminal, the cursor can be changed to a blinking, solid box, a blinking underline, a blinked checkered box, (and probably more that I can't think of right now)
How do I change appearance of the cursor in a JTextArea?
FALL3N
Junior Poster in Training
87 posts since May 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0
hmm, I know how to implement the Caret interface in java code...
ok, I got all the methods to override:
for void addChangeListener(ChangeListener l) I think I can do 'this.addChangeListener(l);'
and for void setVisible(boolean v) I think I can say 'this.setVisible(v);'
but what about for any of the rest?
public void deinstall(JTextComponent c) {}
public int getBlinkRate() { return 0; }
public Point getMagicCaretPosition() { return new Point(0, 0); }
public int getMark() { return 0; }
public void install(JTextComponent c) {}
public void moveDot(int dot) { }
public void paint(Graphics g) { }
public void removeChangeListener(ChangeListener l) {}
public void setBlinkRate(int rate) {}
public void setMagicCaretPosition(Point p) { }
public void setSelectionVisible(boolean v) { }
FALL3N
Junior Poster in Training
87 posts since May 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0
ok I realize that was an unfairly long question, and I change it to can you (or anyone else) explain to me what the install + deinstall methods for the Caret interface do and how they work? Oh, and how to write the two ChangeListener methods... I wrote all the other methods, but those 4 methods keep giving me errors and runtime errors...
FALL3N
Junior Poster in Training
87 posts since May 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0
Yup, thanks a lot, it is much clearer now..
I copied the class and fixed it up a bit.. so now it works fine... Anyway, I am trying to make the Caret a solid box that blinks, like in the terminal.. It starts draws initially correctly, but then after I type anything, it grows to ≈1.5 width, and a little sliver of the caret from the right side is not cleared and left there when the caret blinks..
I could def be wrong (as this is my first experience with Carets) but it seems like I altered the 'paint' method correctly, but then when the rectangular caret is cleared for a blink (as it is supposed to be) part of it stays on the screen and the rest is cleared and redrawn. As a solution, do I have to somehow rewrite the repaint method in the FancyCaret class? (I say somehow because I tried and it said that the original 'repaint()' method is final)
If writing a new redraw() is not the solution, or the whole solution, then what is?
FALL3N
Junior Poster in Training
87 posts since May 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0
damn, I thought I saw an answer here the other day.. damn it.
FALL3N
Junior Poster in Training
87 posts since May 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0