java - Make JOptionPane Print More Than One Set Of Data -


can explain me how can print 3 rows of customer data in 1 dialog box in screenshot below? right prints 1 row @ time.

joptionprint

string custnum = joptionpane.showinputdialog("enter cust numb:");       while (!custnum.equalsignorecase("quit")) {          string custname = joptionpane.showinputdialog("enter cust name:");          {             try {                kilowattused = double.parsedouble(joptionpane.showinputdialog("enter kilowatt(s) used:"));             }             catch (numberformatexception e) {                kilowattused = minkilowatt - 1;             }             if (kilowattused < minkilowatt || kilowattused >= maxkilowatt) {                joptionpane.showmessagedialog(null,"please enter valid number");             }          } while (kilowattused <= minkilowatt || kilowattused >= maxkilowatt);            if (kilowattused < lowratekilowattmin) {             amtowed = kilowattused * highrate;          }          else {             amtowed = kilowattused * lowrate;          }           totalowed += amtowed;          numcustomers++;          joptionpane.showmessagedialog(null,custnum + " | " + custname + " | "              + string.format("%.1f",kilowattused) + " | " + "$" + string.format("%.2f",amtowed));           custnum = joptionpane.showinputdialog("enter cust number:");       } 

the chacter use in java new line new line character \n if add in final string between lines come on seprerate lines:

here simple example demonstrate it:

joptionpane.showmessagedialog(null, "line1 \nline2 \nline3"); 

the output of be:

enter image description here

i hope helps :)


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -