ButtonField listeners

Hi all

I wonder if it is possible to add a ChangeListener to a group of buttons, something like:

groupOfButtons1.setChangeListener (this);

I tried to do it with a HorizontalFieldManager but it did not work.

As far as I KNOW is not possible, but you can add the same ChangeListener to all buttons.

Tags: BlackBerry Developers

Similar Questions

  • My FieldChangeListeners are no longer works

    Hello

    My code is too long to post here so I'll try to explain. I've built a number of calculators with EditFields and ButtonFields, that work well. The ButtonFields have FieldChangeListeners that do things when they are clicked.

    The last calculator to build I added a few TextSpinBoxFields in a PopupScreen. I used the SpinnerDemo to help with the code. So I can make a selection of spinners OK, but now my ButtonField listeners are no longer works. When I click a button the pop-up menu main upwards instead.

    Part of the code SpinnerDemo a navigationClick() and touchEvent() overloaded, so I wonder if they caused the problem.

    If anyone can help with this I would be very happy.

    Ah, Yes. The custom button class is indeed a problem. You need to make it react to the touch of the events. To remove the context menu, you need to uncheck as well as click on the events button. Something like this should do it:

    protected boolean touchEvent(TouchEvent message) {    switch (message.getEvent()) {    case TouchEvent.CLICK:        fieldChangeNotify(1);        // fall through    case TouchEvent.UNCLICK:        return true;    }    return super.touchEvent(message);}
    
  • Question about the program clearing browser history

    Aftre the class implementation and the instructions to import appropriate, I can access URL in an application using these instructions:

    {Private site = Browser.getDefaultSession ();
    site.displayPage ("http://www.whatever.com");

    Is not indicated some managers ButtonField, listeners and a group of if/else instructions that serve the U.I to select a half dozen of them hard coded URL.

    The problem is that whenever the user selects a URL, the selection to become a historic event in the history of the BB browser.

    If I have Import net.rim.device.api.browser.field.HistoryEvent, I would be able to eliminate all the history entries that accumulate in the history of the standard browser or that will not work with this ease of use of the browser?

    If you have done this, you have an example constructor and method of your implementation that you would share?

    Thank you.

    This is not supported.  You cannot programmatically change the browser history.  The class that you reference is designed to be used with a browser field, not the browser BlackBerry itself.

  • sudden error "too many listeners on GPIB.

    Out of the blue, I'm suddenly in the face of this "too many listeners on the GPIB" error, and my PC has found is more all instruments in NOR-MAX. I have a GPIB-USB-HS connected to my PC and 8 instruments (some HP4142b, Keithley instruments, electricity, etc.), Garland with different GPIB cables... I was able to control them in LabVIEW and summer don't saw no problem with it for months.

    Then yesterday, LabVIEW (I have 2012) suddenly hung when I tried to access one instruments (which went in the State "is not responding"). He could see to the recovery, is no longer one of my instruments GPIB on the menu drop down. I rebooted LabVIEW, but still the same thing... could no longer see my GPIB instruments. I rebooted the PC and the same issue. Then, I could see no longer the GPIB instruments in NOR-MAX. I spent a few hours of debugging, try different configurations, connection to 1 or 2 instruments at once... now with this new Setup, I am able to let him see 7 of my instruments, but not all 8. I have a system to Keithley 7001, it doesn't seem to like more... When I connect it to the rest of the GPIB instruments, I get the "too many listeners' error and can not see all the instruments in Max weird because I have two of these 7001 s in my installation, and it is seems ok connection to one but not the other.

    Overall it is really strange and I can't figure out what that might be the problem... would appreciate advice/suggestions.

    I have checked/tried things

    -all GPIB instruments have unique addresses... There is no conflict of interest. as I said, things worked fine before... Suddenly, they were not.

    -doesn't seem to be a problem of GPIB cable. I tried different cables... same cable will be allowed to connect to a single instrument, but when I use it to connect to this particular Keitlhley instead, none of the instruments can be found.

    Also, I just noticed something, don't know if this is important... for my GPIB-USB-HS, the 'Ready' light always seems amber glow... it is never green. And never seems to light 'Active' lights... even if I send orders to the instruments.  Not sure if it of important or not.

    OK, I seem to have solved that problem. I changed address GPIB instrument troublesome Keithley to a number much more than the other instruments (e.g. addr 30 and other instruments were 10, 11, 12, etc.) and it worked. I don't know why it didn't work until he was NOT an address conflict (it was originally addr 9 and no other instrument has this address and it worked fine... just one day he complained there are too many listeners and he could not see what be it... strange. just this announcement here in the case where he helps to anyone.)

  • Avoid the popup on click ButtonField

    Hey guys, rite, I've been looking for centuries now, and the problem I have is that I can't seem to stop the popup to appear, I looked through the forums and although there are a lot of things tell me how to do it, none of them seem to actually tell me how to stop the menu go up when I click on a button.

    I can get the menu to not appear, but then the button does not work.

    Its getting on my nerves now cus its pretty well the last thing I have to do on the entire application.

    Thanks in advance

    Howard

    Add CONSUME_CLICK to the style of the ButtonField.

  • Add ButtonField on BitmapFiled

    Hi all

    I tried to use this code to add BitmapButtonField on BitmapField but I couldn't use it.

    Ant one can help me?

    package mypackage;
    
    import com.operations.images.ImageManipulator;
    
    import net.rim.device.api.system.Application;
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.system.JPEGEncodedImage;
    import net.rim.device.api.ui.TouchEvent;
    import net.rim.device.api.ui.TouchGesture;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.BitmapField;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.SeparatorField;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    /**
     * A class extending the MainScreen class, which provides default standard
     * behavior for BlackBerry GUI applications.
     */
    public final class MyScreen extends MainScreen {
    
        private static int rotatedAngle = 360;
    
        // byte[] rrr = resizeImage(Bitmap.getBitmapResource("gear.png"),
        // Display.getWidth(), Display.getHeight() / 2);
        // Bitmap originalBmp = Bitmap.createBitmapFromBytes(rrr, 0, rrr.length, 1);
        Bitmap originalBmp = Bitmap.getBitmapResource("[email protected]");
        BitmapField rotatedBitmap = new BitmapField(originalBmp);
    
        private BitmapButtonField buttonField1 = new BitmapButtonField(
                Bitmap.getBitmapResource("images_1.png"));
        private BitmapButtonField buttonField2 = new BitmapButtonField(
                Bitmap.getBitmapResource("images_2.png"));
    
        VerticalFieldManager bmpManager = new VerticalFieldManager(USE_ALL_WIDTH
                | NO_HORIZONTAL_SCROLL | NO_VERTICAL_SCROLL) {
    
            public int getPreferredHeight() {
                return rotatedBitmap.getHeight();
            };
    
            public int getPreferredWidth() {
                return rotatedBitmap.getWidth();
            };
    
            protected void sublayout(int maxWidth, int maxHeight) {
    
                layoutChild(rotatedBitmap, originalBmp.getWidth(),
                        originalBmp.getHeight());
                layoutChild(buttonField1, buttonField1.getPreferredWidth(),
                        buttonField1.getPreferredHeight());
                layoutChild(buttonField2, buttonField2.getPreferredWidth(),
                        buttonField2.getPreferredHeight());
    
                setPositionChild(rotatedBitmap, 0, 0);
                setPositionChild(buttonField1, 0, 50);
                setPositionChild(buttonField2, 50, 50);
    
                super.sublayout(getPreferredWidth(), getPreferredHeight());
                setExtent(getPreferredWidth(), getPreferredHeight());
    
            };
        };
    
        VerticalFieldManager manager = new VerticalFieldManager(USE_ALL_WIDTH
                | NO_HORIZONTAL_SCROLL | NO_VERTICAL_SCROLL) {
    
            public int getPreferredHeight() {
                return Display.getHeight() - bmpManager.getPreferredHeight();
            };
    
            public int getPreferredWidth() {
                return Display.getWidth();
            };
        };
    
        /**
         * Creates a new MyScreen object
         */
        public MyScreen() {
            super(USE_ALL_WIDTH | USE_ALL_HEIGHT);
            // Set the displayed title of the screen
            setTitle("Test Animation");
    
            bmpManager.add(rotatedBitmap);
            bmpManager.add(buttonField1);
            bmpManager.add(buttonField2);
    
            manager.add(new SeparatorField());
            manager.add(new SeparatorField());
            manager.add(new LabelField(" label 1 "));
            manager.add(new LabelField(" label 2 "));
            manager.add(new LabelField(" label 3 "));
    
            add(bmpManager);
    
            add(manager);
    
        }
    
        protected boolean touchEvent(TouchEvent message) {
            switch (message.getEvent()) {
            case TouchEvent.CLICK:
                // invokeDialog("-->CLICK");
                return true;
            case TouchEvent.DOWN:
                // invokeDialog("-->DOWN");
                return true;
    
            case TouchEvent.GESTURE:
                TouchGesture gesture = message.getGesture();
                int gestureCode = gesture.getEvent();
    
                if (gesture.getSwipeDirection() == TouchGesture.SWIPE_NORTH) {
                    invokeDialog("swip north : " + gesture.getSwipeAngle() + " , "
                            + gesture.getSwipeMagnitude());
                } else if (gesture.getSwipeDirection() == TouchGesture.SWIPE_SOUTH) {
                    invokeDialog("swip south : " + gesture.getSwipeAngle() + " , "
                            + gesture.getSwipeMagnitude());
                } else if (gesture.getSwipeDirection() == TouchGesture.SWIPE_EAST) {
                    if ((message.getX(1) >= bmpManager.getContentRect().x && message
                            .getX(1) <= bmpManager.getContentRect().width)
                            && (message.getY(1) >= bmpManager.getContentRect().y && message
                                    .getY(1) <= bmpManager.getContentRect().height)) {
    
                        // invokeDialog("swip east : " + gesture.getSwipeAngle()
                        // + " , " + gesture.getSwipeMagnitude());
                        rotate(true);
    
                    }
                } else if (gesture.getSwipeDirection() == TouchGesture.SWIPE_WEST) {
                    if ((message.getX(1) >= bmpManager.getContentRect().x && message
                            .getX(1) <= bmpManager.getContentRect().width)
                            && (message.getY(1) >= bmpManager.getContentRect().y && message
                                    .getY(1) <= bmpManager.getContentRect().height)) {
    
                        // invokeDialog("x = " + bmpManager.getContentRect().x +
                        // " , "
                        // + bmpManager.getContentRect().width + " \ny = "
                        // + bmpManager.getContentRect().y + " , "
                        // + bmpManager.getContentRect().height + "\n mx = "
                        // + message.getX(1) + " , " + message.getY(1));
                        // invokeDialog("swip west : " + gesture.getSwipeAngle()
                        // + " , " + gesture.getSwipeMagnitude());
                        rotate(false);
    
                    }
                }
    
                return true;
    
            case TouchEvent.MOVE:
                // int moveSize = message.getMovePointsSize();
                // int[] x_points;
                // int[] y_points;
                // int[] time_points;
                // int size = message.getMovePointsSize();
                // x_points = new int[size];
                // y_points = new int[size];
                // time_points = new int[size];
                // message.getMovePoints(1, x_points, y_points, time_points);
                //
                // if (x_points.length >= 50) {
                // invokeDialog("-->move : " + size);
                // }else if(x_points.length == 2){
                // invokeDialog("-->move : ssss = " + 2);
                // }
                return true;
            }
            System.out.println("PRINT ME SOMETHING IN ANY CASE");
            return false;
        }
    
        private void rotate(final boolean east) {
    
            synchronized (Application.getEventLock()) {
                UiApplication.getUiApplication().invokeLater(new Runnable() {
    
                    public void run() {
                        // wipe east
                        if (east) {
                            // if (rotatedAngle >= 0) {
                            for (int i = 0; i < 45; i += 1) {
                                try {
                                    rotatedAngle -= i;
                                    rotatedBitmap.setBitmap(ImageManipulator
                                            .rotate(originalBmp, rotatedAngle));
                                    bmpManager.invalidate();
                                    // bmpManager.deleteAll();
                                    // bmpManager.add(new
                                    // BitmapField(rotatedBitmap));
    
                                    // Thread.sleep(100);
                                } catch (Exception e) {
                                }
                            }
                            // }
                        } else {
                            // swipe weast
                            // if (rotatedAngle <= 360) {
                            for (int i = 0; i < 45; i += 1) {
                                try {
                                    rotatedAngle += i;
                                    rotatedBitmap.setBitmap(ImageManipulator
                                            .rotate(originalBmp, rotatedAngle));
                                    bmpManager.invalidate();
                                    // bmpManager.deleteAll();
                                    // bmpManager.add(new
                                    // BitmapField(rotatedBitmap));
    
                                    // Thread.sleep(100);
                                } catch (Exception e) {
                                }
                            }
                            // }
    
                        }
                    }
                });
    
            }
        }
    
        public static void invokeDialog(final String msg) {
            UiApplication.getUiApplication().invokeLater(new Runnable() {
    
                public void run() {
                    Dialog.inform(msg);
                }
            });
        }
    
        public static byte[] resizeImage(Bitmap srcBitmap, int width, int height) {
            // int width = 0;
            // int height = 0;
            // Bitmap srcBitmap = Bitmap.createBitmapFromBytes(image, 0,
            // image.length,
            // 1);
            // if (srcBitmap.getWidth() > srcBitmap.getHeight()) {
            // width = widthT;
            // height = (widthT * srcBitmap.getHeight()) / srcBitmap.getWidth();
            // } else if (srcBitmap.getWidth() < srcBitmap.getHeight()) {
            // height = heightT;
            // width = (height * srcBitmap.getWidth()) / srcBitmap.getHeight();
            // } else {
            // width = widthT;
            // height = heightT;
            // }
            Bitmap destBitmap = new Bitmap(width, height);
            srcBitmap.scaleInto(destBitmap, Bitmap.FILTER_BILINEAR);
            JPEGEncodedImage encoded = JPEGEncodedImage.encode(destBitmap, 100);
            return encoded.getData();
        }
    }
    

    Thank you

    I tried to improve my code and I found the solution

    /**
     * @author : Ahmed Shoeib
     * @description : add BitmapButtonField over BitmapField
     */
    public final class MyScreen extends MainScreen {
    
        Bitmap originalBmp = Bitmap.getBitmapResource("[email protected]");
        BitmapField rotatedBitmap = new BitmapField(originalBmp);
    
        BitmapButtonField buttonField1 = new BitmapButtonField(
                Bitmap.getBitmapResource("images_1.png"));
        BitmapButtonField buttonField2 = new BitmapButtonField(
                Bitmap.getBitmapResource("images_2.png"));
    
        Manager mainManager = new Manager(USE_ALL_WIDTH | NO_HORIZONTAL_SCROLL
                | NO_VERTICAL_SCROLL) {
    
            public int getPreferredHeight() {
                return rotatedBitmap.getHeight();
            };
    
            public int getPreferredWidth() {
                return rotatedBitmap.getWidth();
            };
    
            protected void sublayout(int width, int height) {
    
                setPositionChild(rotatedBitmap, 0, 0);
                layoutChild(rotatedBitmap, rotatedBitmap.getPreferredWidth(),
                        rotatedBitmap.getPreferredHeight());
    
                setPositionChild(buttonField1, getPreferredWidth() / 2, 0);
                layoutChild(buttonField1, buttonField1.getPreferredWidth(),
                        buttonField1.getPreferredHeight());
    
                setPositionChild(buttonField2, getPreferredWidth() / 2,
                        getPreferredHeight() / 2);
                layoutChild(buttonField2, buttonField2.getPreferredWidth(),
                        buttonField2.getPreferredHeight());
    
                setExtent(getPreferredWidth(), getPreferredHeight());
            }
        };
    
        VerticalFieldManager bottomManager = new VerticalFieldManager(USE_ALL_WIDTH
                | NO_HORIZONTAL_SCROLL | NO_VERTICAL_SCROLL) {
    
            public int getPreferredHeight() {
                return Display.getHeight() - mainManager.getPreferredHeight();
            };
    
            public int getPreferredWidth() {
                return Display.getWidth();
            };
        };
    
        /**
         * Creates a new MyScreen object
         */
        public MyScreen() {
            super(USE_ALL_WIDTH | USE_ALL_HEIGHT);
            // Set the displayed title of the screen
            setTitle("Test Animation");
    
            mainManager.add(rotatedBitmap);
            mainManager.add(buttonField1);
            mainManager.add(buttonField2);
    
            bottomManager.add(new LabelField("fffffffffff"));
            bottomManager.add(new LabelField("fffffffffff"));
            bottomManager.add(new LabelField("fffffffffff"));
    
            add(mainManager);
            add(bottomManager);
    
        }
    
    }
    

    Thank you

  • How can I reduce the size of the ButtonField

    Hello

    is it possible to reduce the size of the ButtonField. I want to make the button 50% less of the ButtonField regurla.

    is this possible? If so, how?

    can someone help me please?

    Thank you

    Maury.

    Hi mb1, thank you for your response. It worked for me. And in even, I want the text on the button must also be small. How can I do this? in fact by reducing the button, the button text is displayed as «...» "with 3 points. For example the text of the button 'click here', then after having reduced the size of the buttons, the button text is displayed as «...» ».

    I want the text of the button must be in the very small size.

    How can I achieve this. can you help me please?

    Thank you
    Maury.

  • THIS IS AN EVENT OF A BUTTONFIELD?

    btnCalc private ButtonField = new ButtonField("=")

    {

    public void run () - WARNING: Don't EVER IS USED LOCALLY

    {

    My cod is here!

    }

    };

    The btnCalc is called in the constructor by Add (btnCalc);. But, I Don t know why the vacuum run is not called!... Help please.

    setChangeListener - every field has this method.

  • Align ButtonField Center in HorizontalFieldManger when ObjectChoceField is not selected

    Hello
    I have developed a screen in which there's a topic labelField below that there is an ObjectChoiceField... My position and ObjectChoiceField do not scroll and will remain constant, under the title and ChoiceField object I have some data that must be the subject of a scroll and I could achieve this scrolling thing but my problem is that I place a button below these materials and placed this button in HorizontalFieldManager as follows

    ButtonField back;
    HorizontalFieldManager But_Back = new HorizontalFieldManager (HorizontalFieldManager.FIELD_HCENTER);
    Back = new CustomButtonField ("Back", ButtonField.FIELD_HCENTER);
    Back.setChangeListener (this);
    But_Back.Add (back);

    The first problem: At when only the header of the loading of the page and object coice field and my left side coded hard LabelField will be present and the button below and when I select the value in the ObjectChoiceField then the values corresponding to the labelField letside will be displayed all I can attchieve using the fieldChanged but my button that is currently I am unable to put in the Center... that when the page is loaded without values are present, so the button is to the left side and when I select a value of ObjectChoiceField, then it is aligned to the Center, I want to be at the Center...
    FYI: in the order of scroll implememtn in my Constructori say

    Super (new VerticalFieldManager (), NO_VERTICAL_SCROLL);
    Here I put the code for coice position and object fields in two different HorizontalFieldManager and then announces to the screen
                 
    For the scrolling now, I create a verticalFieldManger like:
    VerticalFieldManager vor = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL |) VerticalFieldManager.VERTICAL_SCROLLBAR);
    and each variable left and right in addition to HorozontalFieldmanger
    HFM HorizontalFieldManager = new HorizontalFieldManager();
    VFM. Add (HFM);

    and at the end I say
    HorizontalFieldManager But_Back = new HorizontalFieldManager (HorizontalFieldManager.FIELD_HCENTER);
    Back = new CustomButtonField ("Back", ButtonField.FIELD_HCENTER);
    Back.setChangeListener (this);
    But_Back.Add (back);
    VFM. Add (But_Back);
    Add (VFM);

    Add Field.USE_ALL_WIDTH in your VerticalFieldManager and DrawStyle.HCENTER in your ButtonField.

    Something like:

    VerticalFieldManager vfm = new VerticalFieldManager(Field.USE_ALL_WIDTH | VerticalFieldManager.VERTICAL_SCROLL | VerticalFieldManager.VERTICAL_SCROLLBAR);
    ///
    ///
    HorizontalFieldManager But_Back = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
    ButtonField  Back = new ButtonField("Back",DrawStyle.HCENTER);
    Back.setChangeListener(this);
    But_Back.add(Back);
    vfm.add(But_Back);
    add(vfm);
    

    Concerning

    Bika

  • Multiline ButtonField

    Is it possible to add more than one tag-line to a Buttonfield?

    Looking for some time, but was not able to find sth. similar...

    dognose

    You must override the method object and draw two or more lines of text via graphics.drawText)

    don't forget to call the super.paint (before).

  • Global events and global event listeners does not work!

    I don't know who to ask if I have questions about knowledge base articles so I'll post here.

    I want to push the alert as how dialog box integrated calendar alerts to users. I understand that I need to use the globalevents and listeners, so I studied it in the knowledge base article below:

    http://supportforums.BlackBerry.com/T5/Java-development/global-events-and-global-event-listeners/TA-...

    However, when I run the code, it does nothing. The way it is set up, it should display messages ("received event, sending accused of receipt and acknowledgement received"), but nothing happens on my Simulator, once I have 'fire' of the global event. Help, please!

    No problem. We were all there at one point.

    Each of these files has a main method that is your entry point to the application. Since everyone has one, they all have two need to have their own projects.

    For example, to create a new project for each of these files in Eclipse (or JDE; Eclipse preferred) and drop the code in., and then run the two projects on the Simulator.

    Once both applications on the sim card, you can then view the interaction between the two applications.

  • Problem with setBorder in a buttonField custom

    Hello world

    I have a custombuttonfield and I FOCUS put border for NORMAL, ACTIVE, and DISABLED using:

    field.setBorder (ButtonField.VISUAL_STATE_NORMAL, BorderFactory.createBitmapBorder,...);

    The thing is that there is a scenario in which the button will not change until its border of development, he stays with the same active border when it is on focus. If I add just a button on the screen, it works fine, but if I add another component the focus state does not work. Is it something related to the method of paint used in the component that was added previously? The two components (button and customlabelField) are added to the manager (verticalfieldmanager) of the delegate.

    Any help would be appreciated

    Thanks and greetings

    Can you post an example that demonstrates this behavior, here or in The Issue Tracker?

    What model of Smartphone BlackBerry and the BlackBerry terminal software version you test on?  You can find this under Options, all on the BlackBerry Smartphone.

  • How to make Custom Bitmap ButtonField background transparent and not black?

    I have a buttonfield bitmaps customized using a png with transparent rounded corners. It appears as a black rectangle with the image on it. How can I make transparent blackground? I think that my problem lies in this code and I tried to use "alpha" with no results:

    Protected Sub paintBackground (Graphics Graphics) {}

    try {}
    graph.setGlobalAlpha (0);
    graph.setBackgroundColor (Color.BLACK);
    Graph.Clear ();
    }
    Finally {}
    }

    I'm sure it's a simple answer, but thanks anyway for the help!

    So I tried to do the same thing to paint override, and now the buttons are not displayed at all the haha. In any case, another programmer has helped me too and came up with the following code, it works and the problem is resolved. Thanks for your help guys, I'll put 'likes' for you. If anyone needs the code here, this is:

    SerializableAttribute public class BitmapButtonField extends {field}
    _onPicture private bitmap;
    _offPicture private bitmap;
    private int id;

    public BitmapButtonField (Bitmap onImage, Bitmap offImage) {}
    Super(Field.FOCUSABLE |) Field.FIELD_HCENTER);
    _offPicture = offImage;
    _onPicture = onImage;
    }

    {public setButtonImage Sub (onImage, offImage Bitmap Bitmap)
    _offPicture = offImage;
    _onPicture = onImage;
    }

    {} public void setButtonId (int id)
    This.ID = id;
    }

    public int getButtonId() {}
    return this.id;
    }

    public int getPreferredHeight() {}
    Return _onPicture.getHeight ();
    }

    public int getPreferredWidth() {}
    Return _onPicture.getWidth ();
    }

    protected void drawFocus (Graphics g, boolean on) {}
    }

    Protected Sub layout (int width, int height) {}
    setExtent (Math.min (width, getPreferredWidth()),
    Math.min (height, getPreferredHeight()));
    }

    Protected Sub paint (Graphics Graphics) {}
    graph.drawBitmap (0, 0, getWidth(), getHeight(), isFocus()? _onPicture: _offPicture, 0, 0);
    }

    protected boolean navigationClick (int status, int time) {}
    fieldChangeNotify (0);
    Returns true;
    }

    {} public boolean keyChar (key char, int status, int time)
    If (key == Characters.ENTER) {}
    fieldChangeNotify (0);
    Returns true;
    }
    Returns false;
    }
    }

  • FieldChangeListener on a ButtonField displays a prompt with named Application Switch and full Menu options dialog box. instead of the action set.

    Hi I use a ButtonField in my class of the screen and adds a ChangeListener and provided the measures required in

    fieldChanged(Field field, int context)
    

    method. But everytime that I click on a button, a dialog box invites you to two play as Application Switch options and full Menu.


    I think that there is a method that must be overridden to avoid this problem. I get this result when I run my app in the device with OS 5.0, but it works fine on the Simulator (7.0).

    Use ButtonField.CONSUME_CLICK as a style.

    your override of navigationclick should also work, but you would raise the event changed yourself field before return true.

  • ButtonField with background

    Hi guys,.

    I have a ButtonField customized with a background image. Here is an excerpt of my layout code

    myWidth = (int) ((double) bgOff.getWidth ());
    myHeight = (int) ((double) bgOff.getHeight ());

    setExtent (myWidth, myHeight);

    This will outline the dimensions of the ButtonField to adapt to that of the background image.

    In my painting method, I use drawBitmap to extract the background image. Here is my code.

    graphics.drawBitmap (0, 0, bgOn.getWidth (), bgOn.getHeight (), bgOn, 0, 0);

    However, this translates the background image that emerges only. I would like to have my main bitmap image on top of the background image. Centralize, if possible. Is it possible to do it this way?

    You probably forgot to put the super.paint (graphics) in your code somewhere - paint does not call as if by magic of painting of the superclass (which is what attracts this button according to focus etc..)

    A cleaner solution would be

    protected void paintBackground(Graphics graphics) {
        graphics.drawBitmap(0,0,getWidth(),getHeight(),bgOn,0,0);
    }
    

    This call is little documented, but it works.  Just look for paintBackground under the screen and you will suddenly discover that it replace another call paintBackground undocumented in the field.

    For what is centralized - you will need a few things for it.  You may be able to do this with Graphics.pushContext ().  Another approach would be like this:

    public class CenteringManager extends Manager {
      private Bitmap _bgOn;
      private int _bgWidth;
      private int _bgHeight;
      private int _width;
      private int _height;
    
      public CenteringManager(Bitmap bg) {
        _bgOn = bg;
        if (_bgOn != null) {
          _bgWidth = _bgOn.getWidth();
          _bgHeight = bgOn.getHeight();
        }
      }
    
      public int getPreferredWidth() {
        return _bgWidth;
      }
    
      public int getPreferredHeight() {
        return _bgHeight;
      }
    
      protected void sublayout(int w, int h) {
        _width = w;
        _height = h;
        if (_bgOn != null) {
          _width = Math.min(_width, _bgWidth);
          _height = Math.min(_height, _bgHeight);
        }
        if (getFieldCount() > 1) {
          throw new IllegalStateException("Cannot center more than one field.");
        }
        if (getFieldCount() > 0) { // there is one!
          Field onlyChild = getField(0);
          int childX;
          int childY;
          layoutChild(onlyChild, _width, _height);
          childX = (_width - onlyChild.getWidth()) / 2;
          if (childX < 0) {
            childX = 0;
          }
          childY = (_height - onlyChild.getHeight()) / 2;
          if (childY < 0) {
            childY = 0;
          }
          setPositionChild(onlyChild, childX, childY);
        }
        setExtent(_width, _height);
      }
    
      protected void paintBackground(Graphics g) {
        if (_bgOn != null) {
          g.drawBitmap(0,0,_width,_height,_bgOn,0,0);
        } else {
          g.clear();
        }
      }
    }
    

    You add your ButtonField to a CenteringManager instance (created in the background image you want) then you add to the screen of the Manager / which you would add normally as ButtonField.

Maybe you are looking for

  • When you download the new Firefox, he did the preferences Options appear in the tabs. where is the option to make a pop-up window?

    In previous versions of Options under the Tools Menu of Firefox window was a separate Firefox window. With the new update they put in the tabs that majorly clutters the space and it is difficult to go back to what I was already looking upward. Y at -

  • IdeaCentre Stick 300 Wi - Fi doesn't work do not

    Hello I just bought Lenovo Ideacentre 300 stick today for having a small home theater PC thing in a small form factor. I plugged it with the HDMI Extender (if I did not I would not be able to press the power button), and it worked. I have connected t

  • Why can I not see an attachment document?

    In the last 3 months, I noticed that whenever I open an attachment that contains the document, it is y no document seen but some gibberish that only a programmer can understand. What's up with that? help please

  • sequence of the RAM on the card mother dx58m01

    I have a dell xps 435mt core i7 920 with a studio card mother dx58m01. There is 6gig ram. 6x1024mb glue 1066 mhz. I want to change ram at 3x2gig sticks memory triple channel 1600 mhz. does anyone know the sequence of installation for this configurati

  • How to load the .xlsx file in table

    Hi allWe all hope you are doing well.I have a test.xlsx file, which is kept in one place on unix server, now I want to load laod this file in the test table.I tried with charger but not get relationships, I tried with positional charger, with positio