java - Adding Values From Combobox To Textfields -
i have login form consisting of 4 fields servername, portnumber, username, password
i have combo-box besides login form should enable users take lastly successful username (e-mail address) able fetch values (servername, portnumber, username, password) text fields. i'm done having username in combo-box.
i need set values regarding username 4 textfields 1 time user take username in combo-box. need help beingness able formulate actionlistener , performed functions. i'm not sure of ones way downwards below. help appreciated. thanks!!
//two lines downwards below, values want assign respective text field string user_name, server_name, port_number; // have got values char [] password; // have got value jtextfield servertext, porttext, usernametext; // jtextfield names set values in jtextfield passwordtext; final jcombobox<string> combobox = new jcombobox<string>(); combobox.additem(user_name); // putting username in combo-box combobox.setbounds(500, -13, 230, 70); panel.add(combobox); combobox.addactionlistener(new actionlistener() { public void actionperformed(actionevent event){ procedure = (string) combobox.getselecteditem(); private void itemstatechanged(itemevent e) { if(e.getstatechange()) == itemevent.selected){ usernametext.settext(user_name); ....... } } } });
that way works in case needs in future. since action, , don't want mirror changes within combo-box itself, i've decided have gone actionlistener rather itemlistener
combobox.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent e){ { servertext.settext( (string) item.getservername()); porttext.settext( (string) item.getportnumber()); usernametext.settext( (string) item.getusername()); passwordtext.settext( (string) item.getpassword()); } } });
java swing combobox textfield
No comments:
Post a Comment