Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 55
Registered: ‎02-08-2010
My Device: Blackberry Bold

Re: LabelField: transparent background

[ Edited ]

Not sure how helpful this is after reading all your posts, but to your original question, a transparent background is pretty simple.

 

 

LabelField lf = new LabelField("Temp") {
	protected void paintBackground(Graphics g) {
		g.setGlobalAlpha(150);
		g.setBackgroundColor(Color.WHITE);
		g.clear();
		super.paint(g);
	}
};

 

 

Developer
Posts: 83
Registered: ‎02-19-2010
My Device: Not Specified

Re: LabelField: transparent background

thanks a lot, know I can choose where I have to define it that it act like i want! :smileyhappy:

Contributor
Posts: 28
Registered: ‎06-02-2010
My Device: 9530

Re: LabelField: transparent background

Dunno if anybody is still looking at this thread, I find this thread most relevant to my need to post.

I tried to use your example but stuck with an all transparent LabelField (both fg and bg)... I need a transparent bg LabelField with some colored text in it.

 

My crude experiments given below:

 

LabelField lblLink = new LabelField("Some text", FIELD_HCENTER | FOCUSABLE)
        {
        	protected void paintBackground(Graphics graphics) {
        	    graphics.setGlobalAlpha(0); // Makes the entire Filed transparent (fg + bg)
        	    graphics.setBackgroundColor(Color.WHITE);
        	    graphics.clear();
        	    super.paint(graphics);
        	}
        	protected void paint(Graphics graphics) {
        	    graphics.setGlobalAlpha(255); // Without it nothing is visible, with it nothing is transparent
                    graphics.setColor(0x000099FF); // A Custom color
        	    graphics.clear();
                    super.paint(graphics);
        	}
        	protected boolean navigationClick(int status, int time) {
        	    // Do my stuff
        	    return true;
        	}
        };

 

 

TIA

 

 

 

Contributor
Posts: 28
Registered: ‎06-02-2010
My Device: 9530

Re: LabelField: transparent background

Dunno if anybody is still looking at this thread, I find this thread most relevant to my need to post.

I tried to use your example but stuck with an all transparent LabelField (both fg and bg)... I need a transparent bg LabelField with some colored text in it.

 

My crude experiments given below:

 

LabelField lblLink = new LabelField("Some text", FIELD_HCENTER | FOCUSABLE)
        {
        	protected void paintBackground(Graphics graphics) {
        	    graphics.setGlobalAlpha(0); // Makes the entire Filed transparent (fg + bg)
        	    graphics.setBackgroundColor(Color.WHITE);
        	    graphics.clear();
        	    super.paint(graphics);
        	}
        	protected void paint(Graphics graphics) {
        	    graphics.setGlobalAlpha(255); // Without it nothing is visible, with it nothing is transparent
                    graphics.setColor(0x000099FF); // A Custom color
        	    graphics.clear();
                    super.paint(graphics);
        	}
        	protected boolean navigationClick(int status, int time) {
        	    // Do my stuff
        	    return true;
        	}
        };

 

 

TIA

 

 

 

Developer
Posts: 83
Registered: ‎02-19-2010
My Device: Not Specified

Re: LabelField: transparent background

Hey CBikram,

 

the background of an label field is transparent per default. But when this field has the focus, the background will be something like dark blue. I solved my problem, as I override the method drawFocus(). It act very good. Here my code:

 

 

protected void drawFocus(Graphics graphics, boolean on){
										graphics.setBackgroundColor(Color.WHITE);
										graphics.setGlobalAlpha(0);
										graphics.clear();
										super.drawFocus(graphics, on);
									
}

 

 

I hope I could help you!

 

Regards

Developer
Posts: 105
Registered: ‎04-24-2012
My Device: blackberry developer

Re: LabelField: transparent background

It is not working above 5.0.
Did you tried it?