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
Accepted Solution

ListField setting background + transparency.

[ Edited ]

Hi,

 

Is there some way to make components like ListFields translucent? (not sure if that's the right term when talking about UIs)


Thanks,

Teja.

 

Edit: Elaborating a bit..

 

1. I have a ListField that I want to set a white background to. How do I do this? I'm already implementing ListFieldCallBack and have the drawListRow overridden. I've tried to do g.setBackground(Color.WHITE), but this doesn't seem to work..

 

Edit2: Tried overriding paintBackground() and using g.setBackground there. Still doesn't work.

 

2. Then I'd like to increase the transparency of the ListField's rows so that the screen background is visible. I was going through the methods in the graphics class, and tried g.setGlobalAlpha(100), but that doesn't seem to work.

 

Thanks again,

Teja.

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: ListField setting background + transparency.

Are you calling Graphics#clear() after you set the background color?

 

Graphics#setBackgroundColor() affects Graphics#clear().

Graphics#setColor() affects Graphics.draw*().

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

Re: ListField setting background + transparency.

Thanks, g.clear() is letting me set the background color.

 

I now have a VerticalFieldManager to which I added a jpeg as a screen background. I need to increase the transparency of the Field to make it show the screen background. My current code -

 

 

add(login = new EditField("Username:","") {
    protected void paintBackground(Graphics g) {
	g.setBackgroundColor(Color.WHITE);
	g.clear();
	g.setGlobalAlpha(100);
	super.paintBackground(g);
    } 
});

Add method - 

 

public void add(Field field) {
    objManager.add(field);
}

 

 

g.setGlobalAlpha is making the text "look" transparent - some shade between black and white, but the background color doesn't change at all.

 

Help?


Thanks,

Teja.

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

Re: ListField setting background + transparency.

[ Edited ]

Whoops, had to put setGlobalAlpha before setting the background. This works, but it makes the text transparent too. Is it possible to make the text look solid and make just the background transparent?

 

 

add(login = new EditField("Username:","") {
	protected void paintBackground(Graphics g) {
		g.setGlobalAlpha(100);
		g.setBackgroundColor(Color.WHITE);
		g.clear();
		super.paintBackground(g);
	}
});

 

Thanks,

Teja.

 

Edit: Overriding the draw* method and settingGlobalAlpha back to 255 before drawing text works.