Java GUI多国语言动态切换

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

上来就给源码,这就是我做事风格

package langue;

/**

* @author HDSSHTLL

*/

import javax.swing.JRadioButtonMenuItem;

import javax.swing.SwingUtilities;

public class NewJFrame extends javax.swing.JFrame {

private static java.util.ResourceBundle resources=

java.util.ResourceBundle.getBundle("langue/softwareResources");

public NewJFrame() {

initComponents();

}

private void initComponents() {

jLabel1 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField();

jLabel2 = new javax.swing.JLabel();

jTextField2 = new javax.swing.JTextField();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jMenuBar1 = new javax.swing.JMenuBar();

jMenu1 = new javax.swing.JMenu();

jRadioButtonMenuItem1 = new JRadioButtonMenuItem();

jRadioButtonMenuItem2 = new JRadioButtonMenuItem();

jRadioButtonMenuItem3 =new JRadioButtonMenuItem();

jRadioButtonMenuItem4=new JRadioButtonMenuItem();

jRadioButtonMenuItem5=new JRadioButtonMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jMenu1.setText("File");

//英语

jRadioButtonMenuItem1.setText("English");

jRadioButtonMenuItem1.addActionListener(new

java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem2.setSelected(false);

jRadioButtonMenuItem3.setSelected(false);

jRadioButtonMenuItem4.setSelected(false);

jRadioButtonMenuItem5.setSelected(false);

resources=java.util.ResourceBundle.getBundle("langue/softwareResources",jav a.util.Locale.ENGLISH);

updateLabel();

}

});

jMenu1.add(jRadioButtonMenuItem1);

//法语

jRadioButtonMenuItem3.setText("france");

jRadioButtonMenuItem3.addActionListener(new

java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem2.setSelected(false);

jRadioButtonMenuItem1.setSelected(false);

jRadioButtonMenuItem4.setSelected(false);

jRadioButtonMenuItem5.setSelected(false);

resources=java.util.ResourceBundle.getBundle("langue/softwareResources",jav a.util.Locale.FRANCE);

updateLabel();

}

});

jMenu1.add(jRadioButtonMenuItem3);

//韩语

jRadioButtonMenuItem4.setText("KOREA");

jRadioButtonMenuItem4.addActionListener(new

java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonMenuItem2.setSelected(false);

jRadioButtonMenuItem1.setSelected(false);

jRadioButtonMenuItem3.setSelected(false);

jRadioButtonMenuItem5.setSelected(false);

相关文档
最新文档