Solved

Implement Blinking Caret

Posted on 2007-03-18
2
701 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 64
eclipse shortcuts 9 63
varialbe initialization 11 37
jboss wildfly 10.1 10 236
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

828 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