Image

Imagev3g4n wrote in Imagejava_dev 😯confused

Listens: Boards of Canada - Happy Cycling

escape characters \t & \n with JOptionPane & FileWriter

So I've modified the code so that JOptionPane and my output .txt file recognize when a new line is necessary by using \r\n instead of earlier when I was just using \n.

Now in regards to tabbing, the .txt file recognizes \t but JOptionPane does not. If I just use spaces, JOptionPane looks perfect but the .txt file isn't all lined up properly. Is there a way of using tab with JOptionPane?


//Output to file and screen.
outputString = (employeeName + "\r\nGross Amount:                     $"
	+ twoDigits.format(grossMonthlyIncome) + "\r\nFederal Tax:                          $"
	+ twoDigits.format(fedTaxDeduction) + "\r\nState Tax:                              $"
	+ twoDigits.format(stateTaxDeduction) + "\r\nSocial Security Tax:            $"
	+ twoDigits.format(socSecTaxDeduction) + "\r\nMedicare/Medicaid Tax:     $"
	+ twoDigits.format(medTaxDeduction) + "\r\nPension Plan:                        $"
	+ twoDigits.format(pensPlanDeduction) + "\r\nHealth Insurance:                 $"
	+ twoDigits.format(HEAL_INSUR) + "\r\nNetPay:                                   $"
	+ twoDigits.format(netMonthlyIncome));


outFile.println(outputString);

JOptionPane.showMessageDialog
	(null, outputString, "Monthly Paycheck", JOptionPane.INFORMATION_MESSAGE);