提交 | 用户 | 时间
|
ce910c
|
1 |
package com.netsdk.common; |
H |
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.FlowLayout; |
|
5 |
import java.awt.Frame; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
import java.awt.event.ItemEvent; |
|
9 |
import java.awt.event.ItemListener; |
|
10 |
import java.awt.event.WindowAdapter; |
|
11 |
import java.awt.event.WindowEvent; |
|
12 |
|
|
13 |
import javax.swing.JButton; |
|
14 |
import javax.swing.JComboBox; |
|
15 |
import javax.swing.JFrame; |
|
16 |
import javax.swing.JPanel; |
|
17 |
import javax.swing.SwingUtilities; |
|
18 |
import javax.swing.UIManager; |
|
19 |
import javax.swing.border.EmptyBorder; |
|
20 |
|
|
21 |
import com.netsdk.common.Res.LanguageType; |
|
22 |
|
|
23 |
/** |
|
24 |
* 选择语言界面Demo |
|
25 |
*/ |
|
26 |
public class SwitchLanguage extends JFrame{ |
|
27 |
private static final long serialVersionUID = 1L; |
|
28 |
|
|
29 |
public SwitchLanguage() { |
|
30 |
setTitle("请选择语言/Please Select Language"); |
|
31 |
setLayout(new BorderLayout()); |
|
32 |
pack(); |
|
33 |
setSize(350, 200); |
|
34 |
setResizable(false); |
|
35 |
setLocationRelativeTo(null); |
|
36 |
|
|
37 |
try { |
|
38 |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
|
39 |
} catch (Exception e) { |
|
40 |
e.printStackTrace(); |
|
41 |
} |
|
42 |
|
|
43 |
add(new SwitchLanguagePanel(this), BorderLayout.CENTER); |
|
44 |
|
|
45 |
this.addWindowListener(new WindowAdapter() { |
|
46 |
@Override |
|
47 |
public void windowClosing(WindowEvent e) { |
|
48 |
dispose(); |
|
49 |
System.exit(0); |
|
50 |
} |
|
51 |
}); |
|
52 |
} |
|
53 |
|
|
54 |
/* |
|
55 |
* 切换语言面板 |
|
56 |
*/ |
|
57 |
public class SwitchLanguagePanel extends JPanel { |
|
58 |
private static final long serialVersionUID = 1L; |
|
59 |
|
|
60 |
public SwitchLanguagePanel(final Frame frame) { |
|
61 |
setLayout(new FlowLayout()); |
|
62 |
setBorder(new EmptyBorder(50, 0, 0, 0)); |
|
63 |
|
|
64 |
String[] CnEn = {"简体中文", "English"}; |
|
65 |
jComboBox = new JComboBox(CnEn); |
|
66 |
|
|
67 |
nextButton = new JButton("下一步"); |
|
68 |
|
|
69 |
add(jComboBox); |
|
70 |
add(nextButton); |
|
71 |
|
|
72 |
jComboBox.addItemListener(new ItemListener() { |
|
73 |
@Override |
|
74 |
public void itemStateChanged(ItemEvent arg0) { |
|
75 |
LanguageType type = jComboBox.getSelectedIndex() == 0 ? LanguageType.Chinese : LanguageType.English; |
|
76 |
Res.string().switchLanguage(type); |
|
77 |
|
|
78 |
if(jComboBox.getSelectedIndex() == 0) { |
|
79 |
nextButton.setText("下一步"); |
|
80 |
} else { |
|
81 |
nextButton.setText("next"); |
|
82 |
} |
|
83 |
} |
|
84 |
}); |
|
85 |
|
|
86 |
nextButton.addActionListener(new ActionListener() { |
|
87 |
@Override |
|
88 |
public void actionPerformed(ActionEvent arg0) { |
|
89 |
SwingUtilities.invokeLater(new Runnable() { |
|
90 |
public void run() { |
|
91 |
frame.dispose(); |
|
92 |
FunctionList functiondemo = new FunctionList(); |
|
93 |
functiondemo.setVisible(true); |
|
94 |
} |
|
95 |
}); |
|
96 |
} |
|
97 |
}); |
|
98 |
} |
|
99 |
|
|
100 |
private JComboBox jComboBox; |
|
101 |
private JButton nextButton; |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
|