java - How to get clicked item in textbox from dropdown listview javafx 8? -
i trying clicked value in textbox, have added listener not getting adjact output. please suggest me how do.
observablelist<string> data5 = fxcollections.observablearraylist(smooth); listview.setitems(data5); listview.getselectionmodel().selecteditemproperty().addlistener( new changelistener<string>() { public void changed(observablevalue<? extends string> ov, string old_val, string new_val) { system.out.println("********"+new_val); txtcustomername.textproperty(); txtcustomername.settext(new_val); } }); public class fillform extends application { text addressone; text addresstwo; text mobileone; text email; @override public void start(stage stage) throws exception { label companynamelbl = new label("company name"); combobox<string> companyname = new combobox<string>(); companyname.seteditable(true); populatecompanyname(companyname); addcombolistener(companyname); hbox companyhbox = new hbox(25); companyhbox.getchildren().addall(companynamelbl, companyname); label addressonelbl = new label("address one"); addressone = new text(); hbox addressonehbox = new hbox(); addressonehbox.getchildren().addall(addressonelbl, addressone); label addresstwolbl = new label("address two"); addresstwo = new text(); hbox addresstwohbox = new hbox(); addresstwohbox.getchildren().addall(addresstwolbl, addresstwo); label mobilelbl = new label("company name"); mobileone = new text(); hbox mobilehbox = new hbox(); mobilehbox.getchildren().addall(mobilelbl, mobileone); label emaillbl = new label("company name"); email = new text(); hbox emailhbox = new hbox(); emailhbox.getchildren().addall(emaillbl, email); vbox form = new vbox(20); form.getchildren().addall(companyhbox, addressonehbox, addresstwohbox, mobilehbox, emailhbox); scene scene = new scene(form); stage.setscene(scene); scene.getstylesheets().add("/combostyles.css"); stage.show(); } private void addcombolistener(final combobox<string> combo) { combo.setonaction(new eventhandler<actionevent>() { @override public void handle(actionevent e) { if (combo.getvalue().equals("apple")) { addressone.settext("\t apple address one"); addresstwo.settext("\t apple address two"); mobileone.settext("\t apple mobile number"); email.settext("\t apple email"); } } }); } public void populatecompanyname(combobox<string> combo) { combo.getitems().add("intel"); combo.getitems().add("apple"); combo.getitems().add("microsoft"); } public static void main(string[] args) { launch(args); } }
combostyles.css
.combo-box .arrow, .combo-box .arrow-button{ -fx-background-color: transparent; } output:
i have made rough illustration without using proper layouts. utilize appropriate layout ui. populate combobox data5 list , in action listener of combo box check selected value , fill other fields.
update
since have utilize text box company said, below links guide in that. have create customized text box extending text class of javafx.
https://github.com/privatejava/javafx-autocomplete-field
http://blog.ngopal.com.np/2011/07/04/autofill-textbox-with-filtermode-in-javafx-2-0-custom-control/
autofill text field jars:
https://code.google.com/p/jfx-autocomplete-textfield/
java netbeans javafx-8
No comments:
Post a Comment