Solved

Implement Blinking Caret

Posted on 2007-03-18
2
696 Views
Last Modified: 2013-12-22
I'm implementing an editor component from scratch (for J2ME environment)
Now I'm totally confused on how to make the caret blink efficiently
A separate thread is used to change the caret's blink-state at regular intervals
But how should I deal with drawing it ?
Should the thread, signal the component (extended from Canvas) to repaint (redrawing everything) ? that would be inefficient in my opinion
It neither can draw directly into the component's Graphics object, only the paint method is responsible for that
Could someone please help me ?
0
Comment
Question by:hoomanv
2 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 18743135
If it turns out that it *is* inefficient (it may be fine to repaint the whole thing, even though as you say it's a bit of a waste of processing), then you could look at managing a "dirty rectangle list" ie, you keep a list of rectangles which need repainting, and only repaint the parts of the screen that are within each rectangle when it comes to redraw...

You will have to handle the case when the whole canvas needs to be redrawn...

Personally, I would see how slow the full repaint is first of all...  as it is the easiest fix...

Maybe, only flicker the cursor once the user has been idle for a fixed time?  That way it is only doing these full repaints once a second or so when the user isn't doing anything else?

Tim
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 18744560
BTW all UI modifications should be done from the EDT so try not to implement another thread to do it/ repaint.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now