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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Custom BitmapButtonField not quite working out

I am looking back at the sample code given.


I can see you have Card objects, and the MainScreen which displays the 'Table'.   So in this code, it seems that the MainScreen should be responsible for listening to the changes and moving the cards


Given this, I think the code you have

Deck deck = new Deck(); //init. deck



actually belongs in the constructor of your Play screen.  This screen should know who the Players are and understand the interaction, not your UiApplication.  This ties in with this screen having the 'Table'. 


In the following code you are making the Object that displays one card responsible for listening to itself:


But the Object that listens for these changes has to be able to see the whole table.  It doesn't make sense for a Card to understand the Table. 


So I would change the change listener for the BitmapButtons to be the screen too.

And in fact, Your BitmapButtons, i would change (as I suggested above) so that they are actually given a default image (to display if they don't have a card) and potentially a card.  Then in their paint method I would display the card image if one was there or the default image. You will need to create removeCard and addCard method for this Object, so that it starts working like a Position on the Table.


Sorry i seem t be repeating myself here, but I think it is very useful to do the Object analysis before you start coding.  A good Object design will make the coding easy, because you know what interaction goes on between your Objects.  You appear to be trying to shoehorn a Position into a BitmapButton, when I think it would be easier for you create a more complicated Object that worked like a Position on the Table.  You've go a lot of this already, you seem to be stuck getting a UiComponent to do what you want, rather than constructing one that does what you want. 


I think I might be rambling, but I hope this helps. 

New Contributor
Posts: 7
Registered: ‎10-20-2011
My Device: Curve 8530
My Carrier: Koodo

Re: Custom BitmapButtonField not quite working out

That does help, thanks. There was some definite shoehorning here. I ran into it with a little more confidence than warranted Smiley Tongue Back to the drawing board.

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Custom BitmapButtonField not quite working out

"I ran into it with a little more confidence than warranted "


Disagree.  I'm betting you have never been on a Object design course, and what you have done so far is good.  There is also a confidence thing, but that is the confidence to write your own Ui code.  Ui on BlackBerry is a dark art, something that I have never really got completely to grips with, I just fumble along.  Look to people like mreed and arkadyz if you want to speak to people who know UI.  Anyway, if you are not familiar with UI stuff it is much easier to take something you know and try to make it work. 


Good job so far.  yes you are going to redo it but you are doing so for the right reasons.