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
Amit_K
Posts: 135
Registered: ‎08-27-2008

Problem in semiTransparent popup screen

Hello Everybody,

 

I am creating the semiTransparent popup screen as follows

 

import net.rim.device.api.system.Bitmap; import net.rim.device.api.system.Characters; import net.rim.device.api.system.KeyListener; import net.rim.device.api.ui.Color; import net.rim.device.api.ui.Graphics; import net.rim.device.api.ui.XYRect; import net.rim.device.api.ui.component.BasicEditField; import net.rim.device.api.ui.component.BitmapField; import net.rim.device.api.ui.component.PasswordEditField; import net.rim.device.api.ui.container.HorizontalFieldManager; import net.rim.device.api.ui.container.VerticalFieldManager; import net.rim.device.api.ui.component.TextField; import net.rim.device.api.ui.container.PopupScreen; public class Login extends PopupScreen implements KeyListener { private TextField txtUserEmail; private Space space; private PasswordEditField txtUserpassword; private BitmapField submitbtn; public Login() { super(new VerticalFieldManager()); try { txtUserEmail = new TextField("", "", 15, BasicEditField.NO_COMPLEX_INPUT |BasicEditField.NO_NEWLINE) { protected boolean keyChar(char key, int status, int time) { if (key != Characters.ENTER) { return super.keyChar(key, status, time); // passing non-enter keys to the parent } else { return true; // just ignoring Enter key, } } protected void paint(Graphics graphics) { //Set this font as a default font for this application. int stipple = graphics.getStipple(); graphics.setStipple(0xFFFFFFFF); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, this.getWidth() - 20, this.getHeight()); graphics.setStipple(stipple); graphics.setColor(Color.DARKGRAY); super.paint(graphics); } }; txtUserpassword = new PasswordEditField("", "", 15, BasicEditField.NO_COMPLEX_INPUT | BasicEditField.NO_NEWLINE) { protected boolean keyChar(char key, int status, int time) { if (key != Characters.ENTER) { return super.keyChar(key, status, time); // passing non-enter keys to the parent } else { return true; // just ignoring Enter key, } } protected void paint(Graphics graphics) { //Set this font as a default font for this application. int stipple = graphics.getStipple(); graphics.setStipple(0xFFFFFFFF); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, this.getWidth() - 20, this.getHeight()); graphics.setStipple(stipple); graphics.setColor(Color.DARKGRAY); super.paint(graphics); } }; submitbtn = new BitmapField(Bitmap.getBitmapResource("submit_off.png"), BitmapField.FOCUSABLE) { public boolean trackwheelClick(int status, int time) { return true; } protected void onFocus(int direction) { setBitmap(Bitmap.getBitmapResource("submit_on.png")); invalidate(); } protected void onUnfocus() { setBitmap(Bitmap.getBitmapResource("submit_off.png")); invalidate(); } public void paint(Graphics graphics) { graphics.setBackgroundColor(Color.BLACK); graphics.clear(); super.paint(graphics); } }; BitmapField cancelbtn = new BitmapField(Bitmap.getBitmapResource("cancel_off.png"), BitmapField.FOCUSABLE) { public boolean trackwheelClick(int status, int time) { System.exit(0); return true; } public void paint(Graphics graphics) { graphics.setBackgroundColor(Color.BLACK); graphics.clear(); super.paint(graphics); } protected void onFocus(int direction) { setBitmap(Bitmap.getBitmapResource("cancel_on.png")); invalidate(); } protected void onUnfocus() { setBitmap(Bitmap.getBitmapResource("cancel_off.png")); invalidate(); } }; // Top margin of the screen space = new Space(0, 30); add(space); // For the UserID TextBox HorizontalFieldManager userIDManager = new HorizontalFieldManager(); space = new Space(20, 0); userIDManager.add(space); userIDManager.add(txtUserEmail); space = new Space(20, 0); userIDManager.add(space); add(userIDManager); // adds the space between UserID and Password Text Boxes space = new Space(0, 10); add(space); // For the Password TextBox HorizontalFieldManager passwordManager = new HorizontalFieldManager(); space = new Space(20, 0); passwordManager.add(space); passwordManager.add(txtUserpassword); space = new Space(20, 0); passwordManager.add(space); add(passwordManager); space = new Space(0, 10); add(space); // Puts the Button at Bottom HorizontalFieldManager btnManager = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);// HorizontalFieldManager.USE_ALL_WIDTH btnManager.add(submitbtn); space = new Space((submitbtn.getBitmapWidth() / 4), 0); btnManager.add(space); btnManager.add(cancelbtn); add(btnManager); space = new Space(10, 10); add(space); } catch (Exception ex) { System.out.println(ex.toString()); } } protected void paintBackground(Graphics g) { try { XYRect myExtent = getExtent(); int color = g.getColor(); int alpha = g.getGlobalAlpha(); g.setGlobalAlpha(0xCC); g.setColor(0x000000); g.fillRoundRect(0, 0, myExtent.width, myExtent.height, 30, 30); g.setColor(color); g.setGlobalAlpha(alpha); } catch (Exception e) { System.out.println(e.toString()); } } protected void applyTheme() { } ///////////////////////////////////// /// implementation of Keylistener ///////////////////////////////////// public boolean keyChar(char key, int status, int time) { boolean retval = false; try { switch (key) { case Characters.ENTER: break; case Characters.ESCAPE: System.exit(0); break; default: retval = super.keyChar(key, status, time); } } catch (Exception e) { System.out.println(e.toString()); } return retval; } /** Implementation of KeyListener.keyDown */ public boolean keyDown(int keycode, int time) { return false; } /** Implementation of KeyListener.keyRepeat */ public boolean keyRepeat(int keycode, int time) { return false; } /** Implementation of KeyListener.keyStatus */ public boolean keyStatus(int keycode, int time) { return false; } /** Implementation of KeyListener.keyUp */ public boolean keyUp(int keycode, int time) { return false; } }

 

 

 for Putting the space in between controls I am using the following space class which extends LabelField class.

 

 

public class Space extends LabelField{ protected int width; protected int height; public Space(int width, int height) { this.width = width; this.height = height; } public int getPrefferedWidth(){ return width; } public int getPrefferedHeight(){ return height; } //overrides the default layout functionality to set the width of the table cell protected void layout(int width, int height) { width = getPrefferedWidth(); height = getPrefferedHeight(); //uses the super class' layout functionality //after the width and the height are set super.layout(width, height); //uses the super class' setExtent functionality //after the width and the height are set super.setExtent(width, height); }// end of method protected void layout }//end of class

 

 

When I move the focus from one control to another then semiTransparent Screen repaints again and the after moving focus several times the transparency of screen disappears and screen becomes opaque.

 

What could be the problem ?

 

and also I am using the transparent images for the button but I am getting the Black background behind the button.

 

Please use plain text.
Administrator
MSohm
Posts: 14,064
Registered: ‎07-09-2008
My Carrier: Bell

Re: Problem in semiTransparent popup screen

You are setting the background color of your BitmapField to black in their paint methods that you are overriding.

 

Can you provide a screenshot of the transparency issue?  What BlackBerry model and handheld software version are you testing with?  You can find this under Options, About on the BlackBerry.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
Amit_K
Posts: 135
Registered: ‎08-27-2008

Re: Problem in semiTransparent popup screen

First of all Thank you very much for your reply.

 

I am setting the background color of my BitmapField to black in paint methods. Ok.

 

I have created the semiTransparent popupscreen using overriding paintBackground method of the Popupscreen.

 

but for highlighting the selected button I have used onFocus,onUnFocus methods of corresponding buttons. if I will not set the background color of buttons then I will not get the hightlight effect. How to set the background color of button to transparent ?

 

I would like to give the screenshot of transparency issue but I don't know how to attach the screen. I tried insert/edit image but I have to insert the image which is on my system.

 

Could you please guide me in this regard.

 

I am running my application on BlackBerry 8130  v4.3.0.59 Emulator

 

Thanks in advance.

Please use plain text.
Administrator
MSohm
Posts: 14,064
Registered: ‎07-09-2008
My Carrier: Bell

Re: Problem in semiTransparent popup screen

You could override the BitmapField.drawFocus method and draw focus on the field using the foreground object (draw a rectangle or something around the field).

 

You can save screen shots of the BlackBerry Simulator by using the Edit menu.  You can save a screen shot of the entire BlackBerry Simulator or just what is shown on the LCD screen.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
Amit_K
Posts: 135
Registered: ‎08-27-2008

Re: Problem in semiTransparent popup screen

[ Edited ]

Thanks for reply.

 

I have to show one bitmap on focus submit_on.png and another bitmap on unfocus submit_off.png event by overriding the drawfocus is not working.

 

and I have taken the screenshot but I have problem in posting to this thread. How can I post to this thread ?

 

Thanks.

Message Edited by Amit_K on 10-15-2008 04:54 AM
Please use plain text.
Administrator
MSohm
Posts: 14,064
Registered: ‎07-09-2008
My Carrier: Bell

Re: Problem in semiTransparent popup screen

The image needs to reside on a web server.  Once there, you can use the Insert image button on the toolbar above the message window (the tree icon) to add the image to your post.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
Amit_K
Posts: 135
Registered: ‎08-27-2008

Re: Problem in semiTransparent popup screen

[ Edited ]

 

In the above screen as I move the trackball the semitransparent screen repaints again I have highlighted the scenario.

 

Thanks in advance

Message Edited by Amit_K on 11-03-2008 05:39 AM
Please use plain text.
Administrator
MSohm
Posts: 14,064
Registered: ‎07-09-2008
My Carrier: Bell

Re: Problem in semiTransparent popup screen

From what I can tell, it looks like the right side red circle has been filled in black, but I don't see the problem on the submit circle.

 

Has anything been drawn on top of the region on the right (prompt, word suggestion box, etc..)?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
Amit_K
Posts: 135
Registered: ‎08-27-2008

Re: Problem in semiTransparent popup screen

Thank you MSohm for response,

 

There is nothing (like prompt, word suggestion box, etc) right side red circle.

 

It becomes black as I roll the trackwheel. It can be clearly noticable if you run the emulator in zoom (200% or more than

 

it ). I have given full code of the screen in this thread.

 

and one more thing that is not repainted with black color also.

 

Please use plain text.