/**
* This file is part of pinyin4j (http://sourceforge.net/projects/pinyin4j/)
* and distributed under GNU GENERAL PUBLIC LICENSE (GPL).
*
* pinyin4j is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* pinyin4j is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with pinyin4j.
*/
package Test_PingYin4j;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
/**
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
* Builder, which is free for non-commercial use. If Jigloo is being used
* commercially (ie, by a corporation, company or business for any purpose
* whatever) then you should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details. Use of Jigloo implies
* acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
* PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
* ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
/**
* A demo show the functions of pinyin4j library
*
* @author Li Min (xmlerlimin@gmail.com)
*
*/
public class Pinyin4jAppletDemo extends JApplet
{
private static final Dimension APP_SIZE = new Dimension(600, 400);
private static final long serialVersionUID = -1934962385592030162L;
private JPanel jContentPane = null;
private JTabbedPane jTabbedPane = null;
private JPanel formattedCharPanel = null;
private JPanel optionPanel = null;
private JButton convertButton = null;
private JPanel buttonPanel = null;
private JTextArea formattedOutputField = null;
private JComboBox toneTypesComboBox = null;
private JComboBox vCharTypesComboBox = null;
private JComboBox caseTypesComboBox = null;
private static String appName = "pinyin4j-2.0.0 applet demo";
/**
* This method initializes charTextField
*
* @return javax.swing.JTextField
*/
private JTextField getCharTextField()
{
if (charTextField == null)
{
charTextField = new JTextField();
charTextField.setFont(new Font("Dialog", Font.PLAIN, 12)); // Generated
charTextField.setText("和"); // Generated
charTextField.setPreferredSize(new Dimension(26, 20)); // Generated
}
return charTextField;
}
/**
* This method initializes unformattedCharPanel
*
* @return javax.swing.JPanel
*/
private JPanel getUnformattedCharPanel()
{
if (unformattedCharPanel == null)
{
unformattedHanyuPinyinLabel = new JLabel();
unformattedHanyuPinyinLabel.setText("Hanyu Pinyin"); // Generated
GridLayout gridLayout = new GridLayout();
gridLayout.setRows(2); // Generated
gridLayout.setHgap(1); // Generated
gridLayout.setVgap(1); // Generated
gridLayout.setColumns(3); // Generated
unformattedCharPanel = new JPanel();
unformattedCharPanel.setLayout(gridLayout); // Generated
unformattedCharPanel.add(getUnformattedHanyuPinyinPanel(), null); // Generated
unformattedCharPanel.add(getUnformattedTongyongPinyinPanel(), null); // Generated
unformattedCharPanel.add(getUnformattedWadePinyinPanel(), null); // Generated
unformattedCharPanel.add(getUnformattedMPS2PinyinPanel(), null); // Generated
unformattedCharPanel.add(getUnformattedYalePinyinPanel(), null); // Generated
unformattedCharPanel.add(getUnformattedGwoyeuRomatzyhPanel(), null); // Generated
}
return unformattedCharPanel;
}
/**
* This method initializes unformattedHanyuPinyinTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getUnformattedHanyuPinyinTextArea()
{
if (unformattedHanyuPinyinTextArea == null)
{
unformattedHanyuPinyinTextArea = new JTextArea();
unformattedHanyuPinyinTextArea.setEditable(false); // Generated
unformattedHanyuPinyinTextArea.setLineWrap(true); // Generated
}
return unformattedHanyuPinyinTextArea;
}
/**
* This method initializes unformattedHanyuPinyinPanel
*
* @return javax.swing.JPanel
*/
private JPanel getUnformattedHanyuPinyinPanel()
{
if (unformattedHanyuPinyinPanel == null)
{
unformattedHanyuPinyinPanel = new JPanel();
unformattedHanyuPinyinPanel.setLayout(new BorderLayout()); // Generated
unformattedHanyuPinyinPanel.add(unformattedHanyuPinyinLabel, BorderLayout.NORTH); // Generated
unformattedHanyuPinyinPanel.add(getUnformattedHanyuPinyinScrollPane(), BorderLayout.CENTER); // Generated
}
return unformattedHanyuPinyinPanel;
}
/**
* This method initializes unformattedTongyongPinyinPanel
*
* @return javax.swing.JPanel
*/
private JPanel getUnformattedTongyongPinyinPanel()
{
if (unformattedTongyongPinyinPanel == null)
{
unformattedTongyongPinyinLabel = new JLabel();
unformattedTongyongPinyinLabel.setText("Tongyong Pinyin"); // Generated
unformattedTongyongPinyinPanel = new JPanel();
unformattedTongyongPinyinPanel.setLayout(new BorderLayout()); // Generated
unformattedTongyongPinyinPanel.add(unformattedTongyongPinyinLabel, java.awt.BorderLayout.NORTH); // Generated
unformattedTongyongPinyinPanel.add(getUnformattedTongyongPinyinScrollPane(), BorderLayout.CENTER); // Generated
}
return unformattedTongyongPinyinPanel;
}
/**
* This method initializes unformattedTongyongPinyinTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getUnformattedTongyongPinyinTextArea()
{
if (unformattedTongyongPinyinTextArea == null)
{
unformattedTongyongPinyinTextArea = new JTextArea();
unformattedTongyongPinyinTextArea.setEditable(false); // Generated
unformattedTongyongPinyinTextArea.setLineWrap(true); // Generated
}
return unformattedTongyongPinyinTextArea;
}
/**
* This method initializes unformattedWadePinyinPanel
*
* @return javax.swing.JPanel
*/
private JPanel getUnformattedWadePinyinPanel()
{
if (unformattedWadePinyinPanel == null)
{
unformattedWadePinyinLabel = new JLabel();
unformattedWadePinyinLabel.setText("Wade-Giles Pinyi
评论2
最新资源