CustomButtonField fieldChanged

This page seems to describe what I do, hoping someone can help me with more details:

http://rim.lithium.com/T5/BlackBerry-App-world-development/click-event-on-the-custom-button/m-p/2943...

So I have a CustomButtonField:

SubmitButton CustomButtonField = new CustomButtonField ("Submit", Color.LIGHTGREY); 65,112,160);
submitButton.setChangeListener (this);

Then, within the same HorizontalFieldManager, I have two standard ButtonFields.

I have a function fieldChanged:

    public void fieldChanged(Field field, int context) {

        if (field == submitButton) {
            submitStart();
        }
        else if (field == testButton) {
            testStart();
        }
    }

If I click on my CustomButtonField, the

if (field == submitButton) {

is NOT true, then he never calls submitStart();

If I click on my standard ButtonField testButton, that if this is true and that it runs testStart() as expected.

Looks like the link above suggests either, I need to have another function fieldChanged specially to my CustomButtonField or I need to access the instance.  I don't know exactly how to start on one of these solutions.

Can you please confirm that when your submitButton is "pressed", that your FieldChanged method is called.  I presume that it is.  In this case, I could absolutely confirm the scope and status of the submitButton object that you create with:

SubmitButton CustomButtonField = new CustomButtonField ("Submit", Color.LIGHTGREY); 65,112,160);

I do not see the code you provided we default unless you have multiple instances of the submitButton, add a different button or update this reference somewhere else in your program, perhaps with another

submitButton = new CustomButtonField (...);

To put on the lines break points

submitButton.setChangeListener (this);

If (field == submitButton) {}

and make sure your reference points submitButton to the same object in two different points.

Tags: BlackBerry Developers

Similar Questions

  • Problem with fieldChanged() and custom button field

    Hello

    I created a custom button class by extending LabelField.  I chose LabelField over field because the LabelField contains desirable properties that are already being implemented.  The only problem I'm having has to do with the change listener.  It seems to 'steal' the event click on other areas in my application.

    For example, when I click on the custom button, a popupscreen with a listfield opens. When I click on an item in the listfield, then the fieldChanged() of custom button is called again...

    Can you see anything wrong with my code?

    package com.rantnetwork.fields;
    
    import com.rantnetwork.app.Constants;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.Ui;
    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public class CustomButtonField extends LabelField {
    
        private boolean highlighted = false;
    
        public CustomButtonField(String text, long style) {
            super(text, style | Field.FOCUSABLE | LabelField.ELLIPSIS);
    
            setPadding(10, 0, 10, 5);
    
            setFont(Font.getDefault().derive(Font.BOLD,
                    Constants.DEFAULT_FONT_SIZE, Ui.UNITS_pt));
    
            setBackground(BackgroundFactory.createLinearGradientBackground(
                    0x163d7c, 0x163d7c, 0x03162d, 0x03162d));
            setBorder(BorderFactory
                    .createBevelBorder(new XYEdges(1, 1, 1, 1), new XYEdges(
                            Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK),
                            new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                    Color.BLACK)));
    
        }
    
        public int getPreferredWidth() {
            return Display.getWidth() / 3;
        }
    
        protected void paint(Graphics graphics) {
            graphics.setColor(Color.WHITE);
            super.paint(graphics);
        }
    
        protected void drawFocus(Graphics graphics, boolean on) {
            // Do nothing
        }
    
        protected boolean navigationClick(int status, int time) {
            fieldChangeNotify(1);
            return true;
        }
    
        protected void onFocus(int direction) {
            if (!highlighted) {
                setBackground(BackgroundFactory.createLinearGradientBackground(
                        0x4bb7df, 0x4bb7df, 0x1b96da, 0x1b96da));
                setBorder(BorderFactory.createBevelBorder(new XYEdges(1, 1, 1, 1),
                        new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                Color.BLACK), new XYEdges(Color.BLACK, Color.BLACK,
                                Color.BLACK, Color.BLACK)));
            }
        }
    
        protected void onUnfocus() {
            if (!highlighted) {
                setBackground(BackgroundFactory.createLinearGradientBackground(
                        0x163d7c, 0x163d7c, 0x03162d, 0x03162d));
                setBorder(BorderFactory.createBevelBorder(new XYEdges(1, 1, 1, 1),
                        new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                Color.BLACK), new XYEdges(Color.BLACK, Color.BLACK,
                                Color.BLACK, Color.BLACK)));
            }
        }
    
        public void showHighlighted(boolean focus) {
            if (focus) {
                highlighted = true;
                setBackground(BackgroundFactory.createLinearGradientBackground(
                        0x4bb7df, 0x4bb7df, 0x1b96da, 0x1b96da));
                setBorder(BorderFactory.createBevelBorder(new XYEdges(1, 1, 1, 1),
                        new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                Color.BLACK), new XYEdges(Color.BLACK, Color.BLACK,
                                Color.BLACK, Color.BLACK)));
            } else {
                highlighted = false;
                setBackground(BackgroundFactory.createLinearGradientBackground(
                        0x163d7c, 0x163d7c, 0x03162d, 0x03162d));
                setBorder(BorderFactory.createBevelBorder(new XYEdges(1, 1, 1, 1),
                        new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                Color.BLACK), new XYEdges(Color.BLACK, Color.BLACK,
                                Color.BLACK, Color.BLACK)));
            }
            invalidate();
        }
    
        public boolean isHighlighted() {
            return highlighted;
        }
    
    }
    

    behrk2 wrote:

    Now, I'm not sure why customButton.setText (calling) would trigger the fieldChanged().  Can anyone think of a reason why he can do?

    Thank you!

    Can you think of a reason why we can't do that? The field has changed, after all! Of course, the context (second argument to fieldChanged) will be PROGRAMMATIC in this case, that might be a pretty good indication for you. But not invoke fieldChanged at all would be wrong.

    This is why I don't like the idea of extending LabelField and not just the field for your custom badges - you have much less control over his behavior. If you want an example showing how to create abstract off-screen buttons, take a look at BaseButtonField and his descendants in managers, fields and advanced buttons.

  • The so-called first fieldChanged or fieldChangeNotify?

    Hi all

    I stumbled upon something that has completely baffled me and I was wondering if I could get a second set of eyes on a problem I encounter.

    I have a page that I build buttons to display with a class of CustomButtonField. In the class, I use the fieldChangeNotify to set the current text of the selected button, thus:

        protected void fieldChangeNotify(int context) {
            try {
                this.getChangeListener().fieldChanged(this, context);
            } catch (Exception e) {}  
    
            setCurrentLabel(this.label);
        }
    

    then call the getCurrentLabel in the main class to retrieve the text of the label and do whatever I want, using the fieldChanged method that comes with FieldChangeListener

       public void fieldChanged(Field field, int context) {
            CustomButtonField cbfi = new CustomButtonField();
            Dialog.alert("Button pressed: " + cbfi.getCurrentLabel());
        }
    

    However, this dialog.alert shows null when I test it, but if it is places in the first method, it works as expected. I wonder if I might have the wrong order in when these methods called when clicking on a button, and the call for a new instance of CustomButtonField is to obliterate the value stored in getCurrentLabel. Either I missed something very simple in reterieving data.

    Regardless, if I could have some thoughts about why it would not work, I would be most grateful...

    Honestly, I'm ready to comment out. The only reason why I currently is to capture the current name of the button that is that is clicked on screen. Cant' seem to find a way to have that captured in the fieldChanged method, which is in the main class instead of the class CustomFieldButton. If there is a way to capture this information within the fieldChange, I'm happy.

    EDIT: I found a solution which is simply embarrassing. Instead use the setCurrentLabel method in the fieldChangeNotify method in CustomButtonField, what I did have points to the current instance of the label of the channel, instead of having a variable so the currentLabel of the getCurrentLabel string value. And in the main class fieldChanged method, I have the following code.

         CustomButtonField cbfi = (CustomButtonField) field;
            Dialog.alert("Button pressed: " + cbfi.getCurrentLabel());
    

    Ugh so simple. Thanks for the help of the people! Very much appreciated.

  • Order of execution within the fieldChanged()

    In the following code example, the EditLead() function is executed at the same time as a dialog box that displays above it.  However, I want the dialog box to appear only after that I left the EditLead() function.

    Any help will be greatly appreciated:

    ' Public Sub fieldChanged (field field, int context) {}

    If {(field.equals (customObjListField))
    selectedIndex int = customObjListField.getSelectedIndex ();

    If (rows.getEmployeeId (selectedIndex) .equals (employeeId)) {}
                   
    UiApplication.getUiApplication () .pushScreen (new EditLead ((Hashtable) tableRows.elementAt (selectedIndex),))
    urlPostField,
    selectedIndex,
    customObjListField,
    lines));
     
    Dialog.Alert ("test");
                         
                   
    }

    }
    }

    Thank you

    Steve

    As an alternative, instead of using pushScreen, you can use pushModalScreen, which blocks until the EditLead screen is closed.

  • Newbie fieldChanged problem

    This is probably a question of beginner full. I use the Eclipse IDE with the BlackBerry plugin. I get an error trying to implement the FieldChangedListener to detect a button. Here's the code.

    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.ButtonField;
    
    public class TestScreen extends MainScreen implements FieldChangeListener{
    
        public TestScreen(){
    
            LabelField labelField = new LabelField("Hello");
            add(labelField);
    
            ButtonField displayButton = new ButtonField("Test", ButtonField.CONSUME_CLICK);
            displayButton.setChangeListener(this);
            add(displayButton);
    
        }
    
        public void fieldChanged(Field field, int context) {
            if ( field.equals(displayButton)){
            Dialog.inform("HI");
            }
        }
    }
    

    I get the error "displayButton cannot be solved" in fieldChanged. I spent a few hours go on it and I can't understand it. Any help would be appreciated.

    Thank you

    Eric

    Eric Hello:

    The problem is that you try to access a variable that is not defined in the scope. Try with this.

    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.ButtonField;
    
    public class TestScreen extends MainScreen implements FieldChangeListener{
    
        ButtonField displayButton;
    
        public TestScreen(){
    
            LabelField labelField = new LabelField("Hello");
            add(labelField);
    
            displayButton = new ButtonField("Test", ButtonField.CONSUME_CLICK);
            displayButton.setChangeListener(this);
            add(displayButton);
    
        }
    
        public void fieldChanged(Field field, int context) {
            if ( field.equals(displayButton)){
            Dialog.inform("HI");
            }
        }
    }
    
  • Help: fieldChanged is not implemented

    Hello

    Please help me on this bug.

    I'm working on BB Storm2 9520, developing on JRE 5.0.0 not JRE (API) 6.0.0

    I created a class BaseScreen, which extends the screen and implements FieldChangeListener

    public abstract class BaseScreen extends MainScreen implements FieldChangeListener{    protected MToolbarButtonField btn1;    protected MToolbarButtonField btn2;    protected MToolbarButtonField btn3;    protected MToolbarButtonField btn4;    protected MToolbarButtonField btn5;    protected ToolbarManager toolbarManager;
    
        public BaseScreen() {        toolbarManager = new ToolbarManager();        HorizontalFieldManager hfm = new HorizontalFieldManager();        hfm.add(btn1);        hfm.add(btn2);        hfm.add(btn3);        hfm.add(btn4);        hfm.add(btn5);        toolbarManager.add(hfm);        setStatus(toolbarManager);    }
    
        public void fieldChanged(Field field, int context)     {        System.out.println("======== Toolbar Button Clicled ========");    }
    
    }
    

    Class MToolbarButtonField extends the ToolbarButtonField class:

    public class MToolbarButtonField extends ToolbarButtonField{    private Bitmap bmpIcon;
    
        public MToolbarButtonField(Bitmap bmp) {        super(Field.FOCUSABLE, bmp);        bmpIcon = bmp;    }
    
        protected void paint(Graphics g) {        //...    }}
    

    Class ToolbarButtonField extends the class of field:

    public class ToolbarButtonField extends Field{    private Bitmap bmpIcon;
    
        public ToolbarButtonField(long style, Bitmap bmp) {        super(style);        bmpIcon = bmp;    }
    
        protected void paint(Graphics g) {        //...    }
    
        protected boolean navigationClick(int status, int time)     {        fieldChangeNotify(1);        return true;    }
    
    }
    

    Then, I created some screens that extends the BaseScreen class and FieldChangeListener tools:

    public class Screen1 extends BaseScreen implements FieldChangeListener{    private BitmapButtonField btn1;    private BitmapButtonField btn2;
    
        public Screen1() {        btn1 = new          BitmapButtonField(Bitmap.getBitmapResource(               "bntmyinfos.png"),              Field.FOCUSABLE| FIELD_LEFT | FIELD_VCENTER);        btn2 = new BitmapButtonField(Bitmap.getBitmapResource(              "bntmycont.png"),              Field.FOCUSABLE| FIELD_LEFT | FIELD_VCENTER);    }
    
        public void fieldChanged(Field field, int context) {        System.out.println("==== Screen1 buttons clicked");        //...    }}
    

    When I clicked on the btn1, btn2 on Screen1, the Screen1.fieldChanged prints to the Console Windows "= Screen1 buttons clicked.

    But when I clicked the btn1 on toolbar, nothing happenned.

    I've already put the style buttons toolbarManager are FOCUSABLE so why nothing is there?

    What should I do to make the BaseScreen.fieldChanged took place?

    Everyone please help.

    Thanks in advance.

    Hi guys,.

    Thank you for your support.

    Now, I already solved the problem.

    And the solution is the fieldChangeNotify (int context) method.

    Add this method in the ToolbarButtonField class, and it works.

    Here is my code that worked:

    ToolbarButtonField

    public class ToolbarButtonField extends Field (    private Bitmap bmpIcon;
    
        public ToolbarButtonField(Bitmap bmp)    {        super(Field.FOCUSABLE);        bmpIcon = bmp;    }
    
        protected void fieldChangeNotify(int context) {           this.getChangeListener().fieldChanged(this, context);       }
    
        protected boolean navigationClick(int status, int time)     {        fieldChangeNotify(1);        return true;    }
    
        protected void paint(Graphics g)    {        //...    }    //...}
    

    and some changes: in BaseScreen, let the fieldChanged method do nothing, change the MToolbarButtonField of extends from ToolbarButtonField to implements FieldChangeListener, and then implement the fieldChanged here method:

    public class MToolbarButtonField implements FieldChangeListener {
        private Bitmap bmpIcon;
        private BaseScreen caller
        private ToolbarButtonField btn1;
        private ToolbarButtonField btn2;
        private ToolbarButtonField btn3;
        private ToolbarButtonField btn4;
        private ToolbarButtonField btn5;
        private VerticalFieldManager toolbarFieldManager;
    
        public MToolbarButtonField(BaseScreen caller) {
            this.caller = caller;
            toolbarFieldManager = new VerticalFieldManager();
    
            btn1 = new ToolbarButtonField();
            btn1.setChangeListener(this);
            btn2 = new ToolbarButtonField();
            btn2.setChangeListener(this);
            btn3 = new ToolbarButtonField();
            btn3.setChangeListener(this);
            btn4 = new ToolbarButtonField();
            btn4.setChangeListener(this);
            btn5 = new ToolbarButtonField();
            btn5.setChangeListener(this);
    
            toolbarFieldManager.add(btn1);
            toolbarFieldManager.add(btn2);
            toolbarFieldManager.add(btn3);
            toolbarFieldManager.add(btn4);
            toolbarFieldManager.add(btn5);
        }
    
        public void addToolbarToScreen()
        {
            caller.setStatus(toolbarFieldManager);
        }
    
        public void fieldChanged(Field field, int context)
        {
            if (field == btn1)
            {
                System.out.println("Button 1 clicked !");
            }
            if (field == btn2)
            {
                System.out.println("Button 2 clicked !");
            }
            if (field == btn3)
            {
                System.out.println("Button 3 clicked !");
            }
            if (field == btn4)
            {
                System.out.println("Button 4 clicked !");
            }
            if (field == btn5)
            {
                System.out.println("Button 5 clicked !");
            }
        }
    }
    

    BaseScreen:

    public abstract class BaseScreen extends MainScreen implements FieldChangeListener
    {
        MToolbar toolbarManager;
        /**
         * Creates a new MyScreen object
         */
        public BaseScreen()
        {
            // Set the displayed title of the screen
            setTitle("Toolbar Button display");
    
            toolbarManager = new MToolbar(this);
            toolbarManager.addToolbarToScreen();
        }
    }
    

    MyScreen (Screen1 last time):

    public class MyScreen extends BaseScreen {
        private ButtonField btn6;
        private ButtonField btn7;
    
        VerticalFieldManager vfm;
    
        public MyScreen()
        {
        vfm = new VerticalFieldManager();
        btn6 = new ButtonField("MyScr button 1", Field.FOCUSABLE);
        btn6.setChangeListener(new FieldChangeListener()
        {
            public void fieldChanged(Field field, int content)
            {
            Dialog.alert("My Screen's button 1 clicked!");
            }
        });
        vfm.add(btn6);
    
        btn7 = new ButtonField("MyScr button 2", Field.FOCUSABLE);
        btn7.setChangeListener(new FieldChangeListener()
        {
            public void fieldChanged(Field field, int content)
            {
            Dialog.alert("My Screen's button 2 clicked!");
            }
        });
        vfm.add(btn7);
    
        this.add(vfm);
        }
    }
    
  • Click here for customButtonfield to consume

    I created a button field custom, which works, but menu appears when you click the button, my custom button field extends the scope only.

    no idea how to block the menu?

    Concerning

    Rakesh shankar. P

    Hi rakesh,

    I think that you are working in the storm. Have you tried FieldChangeListener.if no first then try this...

    If it dint work.

    Try like this

    protected boolean navigationClick (int status, int time) {}

    GotoLink();
    Returns true;
    }
    protected boolean touchEvent (TouchEvent event) {}
    int eventCode = event.getEvent ();
    If (eventCode == TouchEvent.CLICK) {}
    GotoLink();
    Returns true;
    }
    Return super.touchEvent (event);
    }

    private void GotoLink() {}
    If (UiApplication.getUiApplication () .getActiveScreen () .getLeafFieldWithFocus () instanceof CustomButtonField) {}
    Final CustomButtonFieldfocus = (CustomButtonField) UiApplication.getUiApplication () .getActiveScreen () .getLeafFieldWithFocus ();
    If ((attention! = null) & (focus instanceof CustomButtonField)) {}

    / * if(focus == CustomButtonField1) {}

    } else if * / / / code here...

    }

    }

    }

    Thank you & best regards

    pp

  • With the help of CONSUME_CLICK called fieldChanged automatically when setFocus() is called in ButtonField

    Hi all.

    I posted this question before in http://supportforums.blackberry.com/t5/Java-Development/how-to-prevent-occurrence-menu-when-click-a-... but as a thread how on an issue different from the original. Given this is not connected somehow and a problem in itself, I decided to start a new thread. Forgive me if I'm wrong. I'll appreciate a response in one of the two sons

    I have a button that poped a menu when you click on it and going through the forums I found the solution of CONSUME_CLICK style. In fact, the menu popup more but it gave me an undesirable side effect

    Now, it happens that when I put the focus programmatically withbutton.setFocus (, the tracks of methodFieldChangeListener.fieldChange automatically producing unexpected click

    I tried to read the context value, but it is always zero

    How to avoid the popup menu AND the automatic one click when button.setFocus () is called

    I've seen this behavior in my Curve 8520 with v.5.0.0.1036. Simulators v.6.0 as 9300 and 9800 running don't behave this way. They do not have the auto click

    What happens if you just remove the earpiece of change of field (by calling setChangeListener (null)) before you call setFocus() and place it back after that called setFocus?

  • fieldChanged does not correctly variable day

    I have a Setup as follows:

    Screen has

    Screen B

    Screen C

    The screen has a static int public Cash.

    The screen has a labelfield that displays 2 buttons and cash. 1 button push pushing screen b. button 2 C.

    Screen B is pushed and has a random generator that adds to the ScreenA.Cash. This is done automatically when pushed.

    B screen is skipped. Screen a labelField is updated using labelfield.setText ("" + ScreenA.Cash). This works perfectly.

    C screen is pushed and clicking another, it also generates a number. Screen C implements FieldChangeListener. This random number is created inside a 'public Sub fieldChanged '. Inside the fieldChanged, ScreenA.Cash is updated.

    C screen is skipped. Screen that a labelField is updated using .setText again. This does not work perfectly.

    When the C instance screen is executed the first time a random number added to the cash is 25, but after be popped the label Cash will say 0. If I run screen C second once again and say randomly 15, after popping the Silver label said 25. This goes on and on.

    I tried several test variables and looking for the answer but can't find it. I can only think that the ScreenA.Cash updated in part fieldChanged is screwing of memorization of the number. Any ideas, I'm really stuck on this one. Help, please!

    To cover the second point first.

    I did not say that using the static variable has been the cause of the problem or making it is not static would solve the problem.  All I was saying was that from a coding perspective, using static variables is in this way is not, in my opinion, good practices.

    Now, back to the main problem.  The code you provided shows exactly what the problem: your code is:

    UiApplication.getUiApplication () .pushScreen (new screenC());
    T0. SetText ("this is screen C" + screenA.Cash);
    This setText does not work. It seems trolling with 1 click to each update. Screen C uses fieldchanged and update screenA.Cash in this.

    You have wrongly assumed that push the screen stops the Thread at that time here.  This isn't.  If the line:

    T0. SetText ("this is screen C" + screenA.Cash);

    is actually executed before you even see ScreenC.  Put a breakpoint in to confirm.

    If you want this line to be executed once you 'return' ScreenC, then you need to use pushModal, which is

    UiApplication.getUiApplication () .pushModalScreen (new screenC());

  • fieldChange get variables from the main class

    I'm doing a simple calculator that users enter numbers, press on calculate, and the answer is displayed in the status bar.  The problem I have is that when I try to get the EditFields values in the fieldListener, I get an error that says that the variable was not found.  Here is an example of the code that I have:

    public class MyScreen extends MainScreen {
        public MyScreen() {
            super();
            LabelField title = new LabelField("Automotive Loan Calculator", LabelField.ELLIPSIS | LabelField.FIELD_HCENTER);
    .
    .
    .
            EditField sell = new EditField("Selling Price: $", "", 10, EditField.FILTER_REAL_NUMERIC | EditField.FIELD_RIGHT);
    
            EditField taxrate = new EditField("Tax Rate: ", "", 5, EditField.FIELD_RIGHT | EditField.FILTER_REAL_NUMERIC);
    .
    .
    .
    ButtonField button = new ButtonField("Calculate Payment", ButtonField.FIELD_HCENTER);
            CalcButtonListener calculate = new CalcButtonListener();
            button.setChangeListener(calculate);
    .
    .
    .
     final class CalcButtonListener implements FieldChangeListener {
            public void fieldChanged(Field field, int context) {
    
            String sellData = sell.getText();
            float sellVal = 0;
            if (sellData != null && sellData.length() > 0) {
                sellVal = Float.parseFloat(sellData);
            }
            String taxrateData = taxrate.getText();
            float taxrateVal = 0;
            if (taxrateData != null && taxrateData.length() > 0) {
                taxrateVal = Float.parseFloat(taxrateData)/100;
            }
    
            total = sellVal * taxrateVal + sellVal    
    
                LabelField newpmt = new LabelField("Total: " + total, LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH) {
                public void paint(Graphics g) {
                    int x=  g.getColor();
                    g.setColor(Color.GRAY);
                    g.drawRect(0,0,this.getWidth(), this.getHeight());
                    g.fillRect(0,0,this.getWidth(),this.getHeight());
                    g.setColor(Color.WHITE);
                    super.paint(g);
                }
            };
            setStatus(newpmt);
    
            }
        }
    

    Nevermind, I figured it.  I forgot to set them in my code.

  • Stop fieldChange loops

    I use a FieldChangeListener on two fields, and when one of the two fields are changed by the user, the other field is updated by the program.

    For example, I want a change of user to the first field to update the second field and stop.

    A change of user for the second field should update the first field and stop.

    How can I keep it from looping automatically from one to the other?

    Is there a way to determine if the second field is get updated because:

    (1) the first field has been changed by the user or

    (2) the second field has been changed by the user?

    I tried to check if (FieldChangeListener.PROGRAMMATIC), but it is always true.

    Thank you...

    Thanks for the interest.  I found a solution.

    I had two fields (think payment and amount).  Given that the price of the order of the day is fixed, I could change the amount I pay (payment) and the amount I would receive would update.  Or I could change the amount I want to buy and update the payment.

    The problem I had was that because these two areas were controlled by the listener of domain change, as soon as it would automatically update the other, an infinite loop would begin.

    I solved it by creating a new Boolean variable that I set to false by default.

    I check this variable in the fieldChanged method and if it is true, I put it to false and back.

    When the field is changed, I immediately put the new variable to false to stop the loop.

    Here is an excerpt:

    boolean changeLoop = false;        
    
    public void fieldChanged(Field field, int context) {
    
        if (changeLoop) {
            changeLoop = false;
            return;
        }
        if (field instanceof BitmapField) {
            changeLoop = true;
            payment = pricField.getDouble() * quantity.getDouble();
            paymentField.setText(toString(payment);
        }
        if (field instanceof BasicEditField) {
            changeLoop = true;
            payment = Double.parseDouble(paymentField.getText());
            quantity = payment / pricField.getDouble();
            quantityField.setDouble(quantity);
        }
    }
    
  • TouchEvent and fieldChange problem Listener

    Hi all

    I used TouchEvent and fieldChange earpiece in my application.

    but the problem is that I can't activate fieldChangeListener in my application.

    I capture some points on my popup screen with the button.

    This workd OK

    But there is a button on the pop-up screen. The associated fieldchangeListner method never gets activated!

    Can someone help me?

    the button get clicked only by trackball/touchpad

    Thank you

    Afonso Tyagi

    Another option would be to call super.touchEvent and allow normal ButtonField processing to do this for you.

  • fieldChanged()?

    Hi all here.

    I made a button in two States, and I find that: when I click on it via keyboard, its status was changed once (for example: true-> false); When I click on it through the touch screen, its State is a change occurred twice (g true: e.-> false-> true). I have not ever used the 2nd arg fieldChanged (field field, int context) framework, is it has something to do with my problem, or there are other solutions? Thanks in advance.

               public void fieldChanged(Field field, int context)
                {
                    // TODO Auto-generated method stub
                    if(list.getActionState() == true) {
                        startDownload(list);
                    } else {
                        stopDownload();
                    }
                }
    

    You have a touchEvent or navigationClick overridden methods?

    Put a breakpoint in the fieldChanged method and determine which treatment is used to drive each change.

  • FieldChangeListener fieldChanged called several times to EditField?

    Why fieldChanged is called several times in an EditField and how to avoid what is happening or maybe even control how many times the method, I want to be called, is called.

    The debugger that I noticed that my method is running serval times, most of the time + 20 times, and it's ruining the flow of just this is an edit field, is far from avoid this? I'm doing something wrong? or is this a normal behavior?

    I'm past the code if it helps, but if I can get the answers to these questions, am sure I can fix the code myself.

    Thank you

    Nevermind, figured it out, sorry for losing space, bandwidth, etc etc.

  • DoModal and save the FieldChange method

    Hi all

    I have a scenario where the FieldChange event, I must save record and then proceed to a secondary page.

    On FieldChange, I code something like that

    & MY_REC. Save();
    DoModal (Page.MY_PAGE_SEC, "", - 1, - 1);

    But I get the error message
    "Think-time PeopleCode, event (EvalDoModal), but a SQL update occurred in the interval of validation."
    "Think-time PeopleCode events such as messages that require a response from the user can be executed if a SQL, insert, or delete update has occurred in the meantime of validation. Examples of PeopleCode who call the type of SQL update includes process scheduler, TriggerBusinessEvent, or MarkWorked. A unit of work cannot contain both reflection-time events and update SQL type. »

    I would be very grateful if you provide a solution. What I want is, the click of a button, I have to save recording and access to a secondary page.

    Thank you

    Try this

    & MY_REC. Save();
    CommitWork();
    DoModal (Page.MY_PAGE_SEC, "", - 1, - 1);

Maybe you are looking for