Solved

Implement Blinking Caret

Posted on 2007-03-18
2
700 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:Mayank S
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 77
recursion example 16 124
Java Loop 6 59
going to wrong jsp page 2 19
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

785 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