GUI代码部分
/**
* @(#)CnToSpellGUIjava
* kindani
* ??
* */
import javaawt*;
import javaawtevent*;
import javaxswing*;
import javaxswingevent*;
/**
*
*
JDK版本
* @author KIN
* @version
* @see
* @since
*/
public class CnToSpellGUI extends JFrame {
private CnToSpellGUI c = null;
public CnToSpellGUI () {
super(Cn to Spell);
setSize();
getContentPane()setLayout(new FlowLayout());
// component layout
JTextArea from = new JTextArea();
JTextArea to = new JTextArea();
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
baddActionListener(new CnPinyinActionListener(fromto));
setVisible(true);
// set this for pack
c = this;
}
/**button action listener to convert text to pinyin from one textbox to another textbox*/
class CnPinyinActionListener implements ActionListener{
private JTextArea from = null;
private JTextArea to = null;
public CnPinyinActionListener(JTextArea from JTextArea to) {
thisfrom = from;
thisto = to;
}
public void actionPerformed(ActionEvent e) {
if (fromgetText()length() == ) {
JOptionPaneshowMessageDialog(fromFrom text is empty!WarningJOptionPaneWARNING_MESSAGE);
}
String text = fromgetText();
tosetText(CnToSpellgetFullSpell(text));
cpack();
}
}
public static void main(String [] args) {
CnToSpellGUI g = new CnToSpellGUI();
}
}
/**
* @(#)CnToSpelljava
*