这代码什么意思啊
package adasdasdad;import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.text.MessageFormat;
import java.util.Date;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class MyFrame1 extends JFrame implements ActionListener {
public JLabel label1, label2, label3;
public JButton btn1, btn2;
public JTextField userName, userPassword;
static ResourceBundle rs;
static{
//Locale.setDefault(new Locale("en","US"));
rs=ResourceBundle.getBundle("fkjava", Locale.getDefault());
}
public MyFrame1() {
super(rs.getString("title"));
this.setSize(180, 300);
//this.setResizable(false);
this.setLocationRelativeTo(null);
this.setVisible(true);
this.getContentPane().setBackground(Color.GREEN);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
init();
}
private void init() {
Container panel = this.getContentPane();
panel.setLayout(new FlowLayout());
label1 = new JLabel(rs.getString("label1"));
panel.add(label1);
userName = new JTextField(10);
panel.add(userName);
label2 = new JLabel(rs.getString("label2"));
panel.add(label2);
userPassword = new JPasswordField(10);
panel.add(userPassword);
btn1 = new JButton(rs.getString("btn1"));
btn1.setActionCommand("btn1");
btn1.addActionListener(this);
btn1.setEnabled(false);
panel.add(btn1);
btn2 = new JButton(rs.getString("btn2"));
btn2.setActionCommand("btn2");
btn2.addActionListener(this);
panel.add(btn2);
label3=new JLabel(rs.getString("wellcom"));
panel.add(label3);
userName.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (!userName.getText().equals("")) {
btn1.setEnabled(true);
} else {
btn1.setEnabled(false);
}
}
});
}
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case "btn1":
String name=userName.getText();
String password=userPassword.getText();
if("admin".equals(name)&&"123".equals(password)){
String msg=MessageFormat.format(rs.getString("msg"),
name+"---"+password,new Date());
label3.setText(msg);
}else{
label3.setText(rs.getString("error"));
}
break;
case "btn2":
userName.setText("");
userPassword.setText("");
btn1.setEnabled(false);
break;
}
}
public static void main(String[] args) {
new MyFrame1();
}
}
--------------------编程问答-------------------- 国际化,使支持多种语言
补充:Java , Java SE