RSS
热门关键字:  java  Ajax  JSP  JSF  Struts
当前位置 : 首页>Java>列表

JAVA实现把汉字转化成拼音

来源: 作者: 时间:2008-03-03 点击:
 

GUI代码部分:
/**
 * @(#)CnToSpellGUI.java
 * kindani
 * 2004-10-25??
 * */

  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  import javax.swing.event.*;

/**
 * 


 * 
JDK版本
1.4

 * @author   KIN
 * @version  1.0
 * @see
 * @since   1.0
 */
public class CnToSpell2GUI extends JFrame {

 private CnToSpell2GUI c = null;
 
    public CnToSpell2GUI () {
        super("Cn to Spell");
        setSize(800,100);
        getContentPane().setLayout(new FlowLayout());
        // component layout
        JTextArea from = new JTextArea(5,20);
        JTextArea to = new JTextArea(5,20);
        JButton b = new JButton("cn to pinyin");
        getContentPane().add(new JLabel("From:"));
        getContentPane().add(from);
        getContentPane().add(b);
        getContentPane().add(new JLabel("To:"));
        getContentPane().add(to);
        // action handle
        b.addActionListener(new Cn2PinyinActionListener(from,to));
        setVisible(true);
        // set this for pack
        c = this;
    }

    /**button action listener to convert text to pinyin from one textbox to another textbox*/
    class Cn2PinyinActionListener implements ActionListener{

        private JTextArea from = null;
        private JTextArea to = null;
        public Cn2PinyinActionListener(JTextArea from, JTextArea to) {
            this.from = from;
            this.to = to;
        }
        public void actionPerformed(ActionEvent e) {
            if (from.getText().length() == 0) {
                JOptionPane.showMessageDialog(from,"From text is empty!","Warning",JOptionPane.WARNING_MESSAGE);

共11页: 上一页 1 [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] 下一页
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册