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

SIEMENS CIRCUIT BREAKER 1200AMP 600VAC 3POLE FRAME ONLY KP3F120
$3.99
SIEMENS CIRCUIT BREAKER 1200AMP 600VAC 3POLE FRAME ONLY KP3F120 picture SIEMENS BQD BQD345 45 AMP 3 POLE 480Y/277 VAC CIRCUIT BREAKER 45A 3P 480V
$169.95
 SIEMENS BQD BQD345 45 AMP 3 POLE 480Y/277 VAC CIRCUIT BREAKER 45A 3P 480V  pictureLot of 7 Circuit Breaker 20 A 2 Pole 120/240 Cutler Hammer Square D Siemens (L4)
$39.99
Lot of 7 Circuit Breaker 20 A 2 Pole 120/240 Cutler Hammer Square D Siemens (L4) pictureB260H00S01 NEW - Siemens 22K AIC Shunt Trip Circuit Breaker Free UPS Ground
$150.0
B260H00S01  NEW - Siemens  22K AIC Shunt Trip  Circuit Breaker  Free UPS Ground pictureLOT OF 3 SIEMENS DUAL ZONE CONTACT MODULE ZN31U
$3.99
LOT OF 3 SIEMENS DUAL ZONE CONTACT MODULE ZN31U picture






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