Solved

Implement Blinking Caret

Posted on 2007-03-18
2
702 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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
servlet example 17 59
Delete Android all or certain applications data programmatically 9 114
What's wrong with this code? 4 36
Which non-HTML GUI front end to use with Java? 3 52
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

730 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