BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-06-2010, 04:35 AM   #1
imran2k1
Knows Where the Search Button Is
 
Join Date: Jan 2010
Model: 8900
PIN: N/A
Carrier: telus
Posts: 35
Thumbs up FieldchangeListener problem StackoverFlowError

Please Login to Remove!

hi
i have two field,both have their own FieldchangeListener, on one listener i have to change other field vale, and it will be vice-verse too.
but it is giving error "StackOverFlowError".
code example is here!!
Code:
public class MainClass extends UiApplication {
	public static void main(String []arg)
	{
		MainClass inst= new MainClass();
		inst.enterEventDispatcher();
	}
	public MainClass() {
		pushScreen(new myTest());
	}

}
class myTest extends MainScreen{
	BasicEditField b1,b2;
	public myTest() {
		b1=new BasicEditField("first:","one");
		b2=new BasicEditField("second:","two");
		b1.setChangeListener(b1_listener);
		b2.setChangeListener(b2_listener);
		add(b1);
		add(b2);
	}
	FieldChangeListener b1_listener=new FieldChangeListener(){

		public void fieldChanged(Field field, int context) {
			
			b2.setText("set two");
		}
		
	};
	FieldChangeListener b2_listener=new FieldChangeListener(){

		public void fieldChanged(Field field, int context) {
			
			b1.setText("set one");
		}
		
	};
}
if any one know why this exception is coming then reply me.
Thanks and regards
Imran ali
Offline  
Old 07-06-2010, 07:12 AM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

Follow the logic:

b1 sets the data in b2, which causes a call to the listener on b2, which sets the data in b1, which results in a call to the listener on b1, which results in changing b2, causing a call the the listener on b2, etc, etc, etc, until you blow the stack.

Not sure exactly what you are trying to accomplish here, but you might want to take a look at the "Context" variable - this tells you if the data has been set programmatically, or by the user.
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Analog Panel AMP VOLT Current Ammeter Voltmeter Voltage Gauge 10A 50V DH-670 DC  picture

Analog Panel AMP VOLT Current Ammeter Voltmeter Voltage Gauge 10A 50V DH-670 DC

$12.99



Voltmeter Ammeter DC 120V 500A Voltage Current Gauge RV Boat Motor Camper CAR picture

Voltmeter Ammeter DC 120V 500A Voltage Current Gauge RV Boat Motor Camper CAR

$32.50



AC 80-260V 0-100A LCD Digital Display Volt Watt Power Meter Voltmeter Ammeter picture

AC 80-260V 0-100A LCD Digital Display Volt Watt Power Meter Voltmeter Ammeter

$22.50



Battery Tester DC 0-80V0-350A SOC AH VOLT AMP Capacity Tester Voltmeter Ammeter picture

Battery Tester DC 0-80V0-350A SOC AH VOLT AMP Capacity Tester Voltmeter Ammeter

$36.50



LCD Digital Multimeter Voltmeter Ammeter Ohmmeter Volt AC DC Tester Leads Meter picture

LCD Digital Multimeter Voltmeter Ammeter Ohmmeter Volt AC DC Tester Leads Meter

$9.95



Multifunction Digital Multimeter 1999 Counts AC/DC Volt Current Ohm Tester Meter picture

Multifunction Digital Multimeter 1999 Counts AC/DC Volt Current Ohm Tester Meter

$9.95







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