About ComboBox and radio

Source: Internet
Author: User

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 ";
}
}
});

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.