java - Return value of filled JComboBox and using the values to fill JTextField -


i'm coding jframe opens joptionpane through jmenubar. joptionpane have combobox lot of different string values. after jcombobox there jtextfield.

i want text select in jcombobox inserted next jtextfield , updated everytime select new string value in jcombobox.

please help!

class dateiadapter implements actionlistener {  public void actionperformed(actionevent event) {      jmenuitem change = (jmenuitem) event.getsource();      jcombobox allequest = new jcombobox(ah.getline(1)); //this combobox gets lot of different values different class      // actionlistener     actionlistener cbactionlistener = new actionlistener() {          public void actionperformed(actionevent e) {              string s = (string) allquest.getselecteditem(); //gets selected string of jcombobox             system.out.println("\n" + s); // want use string s outside of here,             }         };          allquest.addactionlistener(cbactionlistener);          jtextfield questions = new jtextfield(); //this textfield want insert different values of combobox above         jtextfield a2 = new jtextfield();         jtextfield b2 = new jtextfield();         jtextfield c2 = new jtextfield();         jtextfield answ2 = new jtextfield();          if (change == itemchange) {              final jcomponent[] input = new jcomponent[] {                     new jlabel("you change question here:"),                     allquest,                     quest2,                     a2,                     b2,                     c2,                     answ2,  };              joptionpane.showmessagedialog(null, input, "change question", joptionpane.plain_message); 

you can use

questions.settext(allequest.getselecteditem().tostring()); 

inside actionlistener. questions textfileld should defined above actionperformed method


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -