这是一个CSDNer写的,自己看看吧:import javax.swing.*;
import java.awt.event.*;
import java.awt.*;public class keipe extends JFrame implements ActionListener{
  private JPanel pane=new JPanel();
  private JButton btn=new JButton("确定");
  private JTextField Txt_Number=new JTextField();
  private JLabel Lbl_Result=new JLabel();
  private float Number;
  private boolean isZero;  //最后一位是否为0;
  public keipe(){
    super("金额转换");
    isZero=false;
    pane=(JPanel)this.getContentPane();
    pane.setLayout(new GridLayout(3,1));
    pane.add(Txt_Number);
    pane.add(Lbl_Result);
    pane.add(btn);
    btn.addActionListener(this);
    setSize(200,200);
    show();
  }
  public static void main(String args[]){
    new keipe();
  }
  public void actionPerformed(ActionEvent e){
    String temp=Txt_Number.getText();
    if(temp.length()>=3){
      if(temp.charAt(temp.length()-3)!='.')
        JOptionPane.showMessageDialog(this,"请输入正确的格式%*.**");
      else{
        if(temp.charAt(temp.length()-1)=='0')
          isZero=true;
        Number=Float.parseFloat(temp); //取得数
        Lbl_Result.setText(change(Number));
        Lbl_Result.setForeground(Color.red);
        isZero=false;
      }    }
    else
      JOptionPane.showMessageDialog(this,"请输入正确的格式%*.**");  }
  //实现方法
  public String change(float CurrentNumber){   //输入CurrentNumber的数字格式为%*.**;
    String results=new String("¥");
    String temp;
    final String Units[]={"分","角","元","拾","佰","仟",   //单位
      "万","拾","佰","仟","亿","拾","佰","仟","兆","拾","佰","仟"};
      final String Numbers[]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"}; //大写数
      if(isZero)
        temp=Float.toString(CurrentNumber)+"0";
      else
        temp=Float.toString(CurrentNumber);
      java.lang.StringBuffer buf=new java.lang.StringBuffer(); //处理后的字符串
      char c;
      for(int i=0;i<temp.length();i++){  //去掉小数点
        c=temp.charAt(i);
        if(c!='.')
          buf.append(c);
      }
      System.out.println(buf);
      for(int i=1;i<=buf.length();i++){
        results+=Numbers[buf.charAt(i-1)-48];
        //System.out.println(buf.charAt(i-1));
        results+=Units[buf.length()-i]+" ";
      }
      return results;  }