I recently used ComboBox and radio to look for examples on the Internet, but they couldn't get the results. Then I studied it myself and finally got the results. Now I want to record it:
ComboBox;
Liststore <basemodel> merchantstore = new liststore <basemodel> ();
Merchantstore. Add (GetType ());
ComboBox <basemodel> merchant = new ComboBox <basemodel> ();
Merchant. setfieldlabel ("Merchant :");
Merchant. setdisplayfield ("type ");
Merchant. setemptytext ("= select = ");
Merchant. setstore (merchantstore );
Merchant. settypeahead (true );
Merchant. settriggeraction (triggeraction. All );
Formpanel. Add (merchant, new formdata ("100% "));
Private list <basemodel> GetType (){
List <basemodel> List = new arraylist <basemodel> ();
List = new arraylist <basemodel> ();
Basemodel Bm = new basemodel ();
BM. Set ("type", "cat ");
BM. Set ("key", 1 );
List. Add (BM );
Bm = new basemodel ();
BM. Set ("type", "dog ");
BM. Set ("key", 2 );
List. Add (BM );
Bm = new basemodel ();
BM. Set ("type", "bird ");
BM. Set ("key", 3 );
List. Add (BM );
Bm = new basemodel ();
BM. Set ("type", "other ");
BM. Set ("key", 4 );
List. Add (BM );
Return list;
}
Valid value:
Types. addlistener (events. Change, new listener <componentevent> (){
Public void handleevent (componentevent be ){
ComboBox <basemodel> selectbox = (ComboBox) be. getcomponent ();
Type = selectbox. getvalue (). Get ("type ");
}
});
Radio:
Final radiogroup group = new radiogroup ();
Group. setfieldlabel ("Pet gender ");
Radio first = new radio ();
First. setdata ("key", 1 );
First. setboxlabel ("male ");
First. setvalue (true );
Group. Add (first );
Radio second = new radio ();
Second. setdata ("key", 2 );
Second. setboxlabel ("female ");
Group. Add (second );
Formpanel. Add (Group, New formdata ("100% "));
Value;
Group. addlistener (events. Change, new listener <baseevent> (){
Public void handleevent (baseevent be ){
Radiogroup selectedradiogroup = (radiogroup) (fieldevent) be). getcomponent ();
String Haha = selectedradiogroup. getvalue (). getdata ("key") + "";
If (haha. Equals ("1 ")){
Sex = "male ";
}
If (haha. Equals ("2 ")){
Sex = "female ";
}
}
});