import java.awt.*; import java.applet.*; import java.awt.event.*; import java.text.*; public class NumToString2 extends Applet implements ActionListener { NumberFormat nf, cf, pf; TextField numTF = new TextField(10); Label numLbl = new Label("Numeric Output "); Label curLbl = new Label("Currency Output"); Label pctLbl = new Label("Percent Output "); public void init() { nf = NumberFormat.getNumberInstance(); cf = NumberFormat.getCurrencyInstance(); pf = NumberFormat.getPercentInstance(); add(numTF); add(numLbl); add(curLbl); add(pctLbl); numTF.addActionListener(this); } public void actionPerformed(ActionEvent e) { String sVal = numTF.getText(); Double bigD = new Double(sVal); String sFmt = nf.format(bigD); numLbl.setText(sFmt); sFmt = cf.format(bigD); curLbl.setText(sFmt); sFmt = pf.format(bigD); pctLbl.setText(sFmt); } }