BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 10-20-2011, 03:47 PM   #1 (permalink)
New Member
Join Date: Oct 2011
Model: 8530
Carrier: Koodo
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Custom BitmapButtonField not quite working out

Please Login to Remove!

So I'm a new Java/BB developer, more familiar with PHP than anything. I haven't used Java in a while and made the decidedly ill-advised decision of relearning Java through the Blackberry JDE. I decided to start off with a 'simple' Italian card game. It's pretty messy as I just sort of threw it together as I ran into problems and solved them.

My plan was to show the 3 cards in your hand at the bottom, and have them focusable, and selectable. Once selected I want to take the card out of your hand, put it on the table, and change the bitmapField image.

I made a custom BitmapButton class that extends BitmapField, making it focusable, and overriding navigtionUnclick(). On nUnclick, it sends a notification to the FieldChangeListener. Problem is, I can't set everything to final, and therefore can't do anything with my buttons now. Is there another method to do what I'm trying to do? I've been searching and rewriting for days.

The only way I can refer to any outside objects or variables is to declare them final.




Anyways, here's the code for the BitmapButton:
 *  <your company here>, <year>
 * Confidential and proprietary.

package Briscola;

import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Graphics;

public class BitmapButton extends BitmapField {
            private Bitmap normal;
            private Bitmap focus;
            BitmapButton(Bitmap bitmap, Bitmap focusImg){
                normal = bitmap;
                focus = focusImg;
            public boolean isFocusable() {
                return true;
            public void onFocus(int direction){
            public void onUnfocus(){
            protected void drawFocus(Graphics _g, boolean _on) {  /* do nothing */ }
            protected void paint(Graphics graphics)
                graphics.setColor( 0xF2DE57 );
            protected boolean navigationUnclick(int status, int time) {
                return true;
And, here's the area in question:
/*-- Setup Playing Field --*/
                HorizontalFieldManager inPlay = new HorizontalFieldManager();
                BitmapField play1 = new BitmapField(Bitmap.getBitmapResource("Holder.png"));
                BitmapField play2 = new BitmapField(Bitmap.getBitmapResource("Holder.png"));
                BitmapField briskImg = new BitmapField(brisk.face);
                int Turn = 1; //P1 Turn                
                HorizontalFieldManager inHand = new HorizontalFieldManager();
                /**/one = new BitmapButton(P1.hand[0].face,P1.hand[0].focus);
                /**/two = new BitmapButton(P1.hand[1].face,P1.hand[1].focus);
                /**/three = new BitmapButton(P1.hand[2].face,P1.hand[2].focus);
                FieldChangeListener fcm = new FieldChangeListener() {
                      public void fieldChanged(Field field, int context) {
                                Dialog.alert("first card");
                                Dialog.alert("second card");
                                Dialog.alert("third card");
I want to change the image of the BitmapButton pressed, as the card shouldn't be in your hand once it's been played obviously, as well as that of either play1 or play2, depending on who's turn it is.

The card game is Briscola if anyone is interested.
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Custom BitmapButtonField not quite working out
Thread Thread Starter Forum Replies Last Post
want to assign custom ringtone, but not message alert... andrewbashuk General 9700 Series Discussion - Bold 2 0 02-24-2010 11:14 AM
Location API not working for custom/third-party applications nikhilbelsare Developer Forum 1 02-26-2009 09:39 AM
Blackberry Storm 9500 on AT&T, working except gqstatus05 General 9500 Series Discussion - Storm 5 01-30-2009 06:35 PM
Mic not working... FijiParisi General 8100 Series Discussion - Pearl 5 01-20-2007 11:20 AM
TMobile My Faves Custom Ring Tones Not Working! Ugh! fruitfly General 8100 Series Discussion - Pearl 5 01-14-2007 11:25 AM

New 554-BLACKBERRY SMOKE Lukas Nelson Winter Tour Dates 2018 T-Shirts Size S-4xl
New 554-BLACKBERRY SMOKE Lukas Nelson Winter Tour Dates 2018 T-Shirts Size S-4xl pictureFitz And Floyd Blackberry Rabbit Pitcher
Fitz And Floyd Blackberry Rabbit Pitcher pictureEreplacement BAT-17720-002-ER BATTERY F/BLACKBERRY BOLD/CURVE
Ereplacement BAT-17720-002-ER BATTERY F/BLACKBERRY BOLD/CURVE pictureNew 554-BLACKBERRY SMOKE Lukas Nelson Winter Tour Dates 2018 T-Shirts Size S-4xl
New 554-BLACKBERRY SMOKE Lukas Nelson Winter Tour Dates 2018 T-Shirts Size S-4xl pictureNew 554-BLACKBERRY SMOKE Lukas Nelson Winter Tour Dates 2018 T-Shirts Size S-4xl
New 554-BLACKBERRY SMOKE Lukas Nelson Winter Tour Dates 2018 T-Shirts Size S-4xl picture

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.