07-17-2008 12:09 PM
Quote from the previous forum:
When I ran the code you have above, my status background colour was red. Is this not what you are seeing? If so, please provide the BlackBerry model and handheld software version you are testing with. You can find this under Options, About.
Or if you are trying to do something else, please elaborate.
I was testing this in the BlackBerry Simulator included with the version 4.5.0 BlackBerry JDE (4.5.0.44).
Solved! Go to Solution.
07-18-2008 01:08 AM
07-18-2008 10:49 AM
To do this in version 4.1, first call getColor and save the current colour. Then call setColor, setting the colour to the colour you want to use for the background. After that call call fillRect, starting at 0, 0 and going to the size of the field (use this.getWidth() and this.getHeight() to get this). This should fill the entire field with your specified colour.
To allow for drawing of the default field contents call setColor again, passing in the original color and then call super.paint.
07-30-2008 12:23 AM
Firstly Thanks MSohm. I used this scenario, it is very useful to me.But its tuck in one case.
Actually I am using statusBar to show the username, It can be long.So I am using this:
statusField = new LabelField(username,LabelField.FIELD_HCENTER|Label
LabelField.NON_FOCUSABLE );
But when I am using this with paint():
statusField = new LabelField(" ",LabelField.FIELD_HCENTER|LabelField.HCENTER|Labe
LabelField.NON_FOCUSABLE ){
public void paint(Graphics g) {
int x= g.getColor();
g.setColor(Color.LINEN);
g.fillRect(0,0,this.getWidth(),this.getHeight());
g.setColor(Color.BLUE);
super.paint(g);
}
};
It color only those area which is used by text. Please Help me to sort out this situation.
07-30-2008 09:49 AM
You can add the LabelField.USE_ALL_WIDTH style to your LabelField.
07-31-2008 12:01 AM
I had already tried with this style but problem is there when user name is long and we want to show this username in multiline then it doesn't show this in multiline. For this we removed LabelField.USE_ALL_WIDTH and used LabelField.USE_ALL_HEIGHT.
07-31-2008 11:48 AM
08-04-2008 07:20 AM - edited 08-04-2008 07:37 AM
Hi,
I too facing the same problem.
I have a custome labelfield and i want to use the objects of my labelfield as my Statusmessages in my application.
My application consists of 5 screens and i need to update the status messages of each screen depending on some criteria.
****************************************************************
class BCSColoredStatusField extends LabelField
{
int color=Color.RED;
int bgColor= Color.ALICEBLUE;
/**
* Calling the Constructor of its Super class
* @param label String to be displayed
*/
public BCSColoredStatusField(String label)
{
super(label,LabelField.USE_ALL_WIDTH|LabelField.FIELD_HCENTER|LabelField.HCENTER|LabelField.USE_ALL_ HEIGHT);
}
/**
* Calling the Constructor of its Super class
*/
public BCSColoredStatusField()
{
super("",LabelField.USE_ALL_WIDTH|LabelField.FIELD_HCENTER|LabelField.HCENTER|LabelField.USE_ALL_HEI GHT);
}
/**
* Coloring the Backgorund and Text of the field
* @param g graphics object
*/
public void paint(Graphics g)
{
g.getBackgroundColor();
g.setBackgroundColor(bgColor);
g.clear();
// g.fillRect(0,0,Graphics.getScreenWidth(),this.getHeight());
g.getColor();
g.setColor(color);
//g.setFont(g.getFont().derive(Font.BOLD));
super.paint(g);
}
/**
* Initialising with the data member color
* @param color color value to be shown
*/
public void setFontColor(int color)
{
this.color=color;
}
/**
* Initialising with the data member bgColor
* @param color color value to be shown
*/
public void setBackGroundColor(int bgColor)
{
this.bgColor = bgColor;
}
}
*************************************************************************
In myScreen class i have
private static BCSColoredStatusField statusLbl = new BCSColoredStatusField("Scanner not Connected");
setStatus(statusLbl);
then the expexted result is..
But iin some screens i got the result as.
Could you please help me to solve this issue...
Thank You
Jobin

08-04-2008 07:27 AM
08-07-2008 11:51 AM