📄 window01.java
字号:
package view;
import java.awt.BorderLayout;
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.WindowEvent;
import java.awt.event.WindowListener;
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 utiloper.OperUtil;
public class Window01 extends JFrame implements ActionListener,WindowListener {
String[] colorNames = {"red","blue","green","black","yellow","pink","white","orange"};
Color[] colors = {Color.RED,Color.BLUE,Color.GREEN,Color.BLACK,Color.YELLOW,Color.PINK,Color.WHITE,Color.ORANGE};
JTextField jt01;
JPasswordField jt02;
public void dWindow(){
setTitle("登陆后台");
Container container = this.getContentPane();
jt01=new JTextField(12);
jt02=new JPasswordField(12);
JPanel jp1=new JPanel();
JPanel jp2=new JPanel();
JPanel jp3=new JPanel();
JLabel j1=new JLabel("用户名");
JLabel j2=new JLabel("密码");
JButton button01=new JButton("提交");
JButton button02=new JButton("取消");
jp1.add(j1);
jp1.add(jt01);
jp2.add(j2);
jp2.add(jt02);
jp3.add(button01);
jp3.add(button02);
addWindowListener(this);
button01.addActionListener(this);
button02.addActionListener(this);
BorderLayout bl = new BorderLayout();
jp1.setLayout(new FlowLayout());
jp2.setLayout(new FlowLayout());
jp3.setLayout(new FlowLayout());
container.add(jp1,BorderLayout.NORTH);
container.add(jp2,BorderLayout.CENTER);
container.add(jp3,BorderLayout.SOUTH);
button01.setBackground(colors[5]);
button02.setBackground(colors[2]);
setVisible(true);
pack();
}
public static void main(String[] args){
Window01 wd=new Window01();
wd.dWindow();
}
public void actionPerformed(ActionEvent arg0) {
if(arg0.getActionCommand().equals("提交")){
OperUtil.checkLogin(jt01.getText(), Integer.parseInt(jt02.getText()));
}
if(arg0.getActionCommand().equals("取消")){
System.exit(0);
}
}
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosing(WindowEvent arg0) {
System.exit(0);
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -