i creating program class pizza ordering form. have code set whatever selection chosen placed textfield called getmetheorder. put selections picked text file receipt of order.
this how set list , working out issue.
object selected[] = toplist.getselectedvalues(); string tops = ""; // use loop obtain names of selected items (int k = 0;k < selected.length ; k++ ) { tops += selected[k] + ","; } getmetheorder.settext( sizepicked + tops ); string[] selecteditems = new string[selected.length]; for(int i=0; i<selected.length;i++){ selecteditems[i] = selected[i].tostring();
i make when user selects pepperoni, peppers , mushrooms example, insert text file.
try { bufferedwriter out = new bufferedwriter(new filewriter("yourpizzaorder.txt")); out.write("thank using online pizza ordering program."); out.newline(); out.write("your order created on"+" "+today); out.newline(); out.write("*------------------------------------------------------*"); out.newline(); out.write("a " + sizepicked + " "+ //this want items jlist appear ); out.close(); } catch (ioexception e) { system.out.println("exception "); }
the sizepicked variable button group selection of small, medium, , large. working , outputting text file planned. bit confused on how list selection appear.
you like...
stringbuilder sb = new stringbuilder(64); (string value : selecteditems) { if (sb.length() > 0) { sb.append(", "); } sb.append(value); } out.write("a " + sizepicked + " "+ sb.tostring());
Comments
Post a Comment