📄 loginframe.java
字号:
package com.sccp.StudentMS.baseFrame;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import com.swtdesigner.SwingResourceManager;
import javax.swing.JOptionPane;
public class LoginFrame extends JFrame {
private JPasswordField p;
private JTextField a;
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
try {
LoginFrame frame = new LoginFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the frame
*/
public LoginFrame() {
super();
setTitle("欢迎进入登录界面");
setBounds(100, 100, 425, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JPanel panel = new JPanel();
panel.setBackground(new Color(237, 249, 254));
panel.setLayout(null);
getContentPane().add(panel, BorderLayout.CENTER);
final JButton button = new JButton();
button.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if(a.getText().equals("admin")&&p.getText().equals("admin"))
{
MainFrame mf=new MainFrame();
mf.setVisible(true);
LoginFrame.this.dispose();
}else
{
JOptionPane.showMessageDialog(null,"帐号或密码错误!");
LoginFrame.this.dispose();
}
}
});
button.setText("确定");
button.setBounds(236, 213, 83, 23);
panel.add(button);
final JButton button_1 = new JButton();
button_1.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
LoginFrame.this.dispose();
}
});
button_1.setText("取消");
button_1.setBounds(333, 213, 82, 23);
panel.add(button_1);
final JLabel label = new JLabel();
label.setFont(new Font("", Font.BOLD, 16));
label.setText("帐号");
label.setBounds(254, 42, 65, 18);
panel.add(label);
final JLabel label_1 = new JLabel();
label_1.setFont(new Font("", Font.BOLD, 16));
label_1.setText("密码");
label_1.setBounds(259, 117, 60, 15);
panel.add(label_1);
a = new JTextField();
a.setBounds(254, 71, 112, 26);
panel.add(a);
p = new JPasswordField();
p.setBounds(254, 150, 112, 24);
panel.add(p);
final JLabel l2 = new JLabel();
l2.setIcon(SwingResourceManager.getIcon(LoginFrame.class, "/images/l1.gif"));
l2.setText(" ");
l2.setBounds(0, 0, 291, 226);
panel.add(l2);
//
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -