BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-19-2010, 02:27 PM   #1 (permalink)
New Member
 
Join Date: Feb 2010
Model: 8320
PIN: N/A
Carrier: T-Mobile
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to force a field to repaint?

Please Login to Remove!

I am using the TableLayoutManager to layout some fields. I have extended that class to paint grid lines and background colors for each field by overriding the paint method for this manager.

When I paint a color in a particular cell, it covers up the contents of the field in that cell. I want to call the field's invalidate method to force a repaint of the field's contents after I paint a color in the cell. However, I get an error when I try to call the field's invalidate method - "The method invalidate() from the type Field is not visible."

There are too many lines of code to paste, so here are the highlights:

Code:
public class TableLayoutManagerGrid extends TableLayoutManager {

    // Constructors, methods to set cell attributes, etc.

    public void paint (Graphics g) {
        super.paint(g);
        // some drawing routines
        Field f = this.getField(index);
        f.invalidate();
    }
}
And then in the main class I add Fields to the TableLayoutManagerGrid as normal. The fields are displayed correctly and all the paint routines paint the fields and borders correctly. I was just adding this final touch to be able to paint a cell with a background color and then have the contents of the cell (i.e.. the Field) repaint itself over this background color.

The invalidate() method is protected in the class Field, so how do I invalidate a Field?

Thanks,

Mark
Offline  
Old 02-19-2010, 03:25 PM   #2 (permalink)
New Member
 
Join Date: Feb 2010
Model: 8320
PIN: N/A
Carrier: T-Mobile
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

FWIW, the solution is to call super.paint() after I paint the borders.

Mark
Offline  
Old 02-19-2010, 03:26 PM   #3 (permalink)
New Member
 
Join Date: Feb 2010
Model: 8320
PIN: N/A
Carrier: T-Mobile
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

P.S. And do not call Field.invalidate() within a paint method - it will cause an infinite loop!!
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.