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
Highlighted
Contributor
Posts: 20
Registered: ‎04-14-2010
My Device: tour 9650
My Carrier: indosat
Accepted Solution

switch button object choices

hello, master .. please help me, I have two button options object code .. how to swap Button A to button B and vice versa..

 

String[] objects1 ={"Indonesia","English","Chinese"};
String[] objects2 ={"Indonesia","English","Chinese"};

ChoiceB1 = new ObjectChoiceField("From:", objects1,0,0)
    		{
                public int getPreferredHeight() 
                {
                    return 10;
                }
                
                public int getPreferredWidth() 
                {
                    return 240;
                }

                public void layout(int width, int height) 
                {
                    setExtent(getPreferredWidth(), getPreferredHeight());
                    super.layout(getPreferredWidth(), getPreferredHeight());
                }
            };
            ChoiceB2 = new ObjectChoiceField("   To:", objects2,0,0)
    		{
                public int getPreferredHeight() 
                {
                    return 10;
                }
                
                public int getPreferredWidth() 
                {
                    return 240;
                }

                public void layout(int width, int height) 
                {
                    setExtent(getPreferredWidth(), getPreferredHeight());
                    super.layout(getPreferredWidth(), getPreferredHeight());
                }
            };	
            
            HorizontalFieldManager fieldmanager = new HorizontalFieldManager(USE_ALL_WIDTH);
            fieldmanager.add(ChoiceB1);
            fieldmanager.add(ChoiceB2);

                this.add(fieldmanager);

 

 

Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: switch button object choices

Didnt get u wat u want?
Contributor
Posts: 20
Registered: ‎04-14-2010
My Device: tour 9650
My Carrier: indosat

Re: switch button object choices

yes. i want create button swap for swap object1 to object2..  you can help me? Smiley Sad

Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: switch button object choices

you want object1 values to save in object2 at run time?
Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: switch button object choices

[ Edited ]

One way you can do like this,

 ChoiceB2 = new ObjectChoiceField("   To:", objects1,0,0)
 {
       public int getPreferredHeight() 
        {
        	return 10;
        }                 
        public int getPreferredWidth() 
        {
        	return 240;
       	}
       	public void layout(int width, int height) 
       	{
       		setExtent(getPreferredWidth(), getPreferredHeight());
       		super.layout(getPreferredWidth(), getPreferredHeight());
       	}
   };            
 HorizontalFieldManager fieldmanager = new HorizontalFieldManager(USE_ALL_WIDTH);
  fieldmanager.add(ChoiceB1);
  fieldmanager.add(ChoiceB2);
  this.add(fieldmanager);
  ChoiceB2.setEnabled(false);
  ChoiceB1.setChangeListener(new FieldChangeListener()
  {	
	public void fieldChanged(Field field, int context) 
	{
		ChoiceB2.setEnabled(true);
        }
});