java围棋代码用户登录 js围棋( 三 )


import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
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.JTextField;
public class dengru extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
private Container c = null;
private JButton jb = null;
public dengru() {
this.setLayout(new FlowLayout());
jb = new JButton("登入");
jb.addActionListener(this);
this.add(jb);
this.setSize(500, 400);
this.setVisible(true);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
public static void main(String[] args) {
newdengru();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jb) {
JFrame jf=new JFrame();
c = jf.getContentPane();
c.setLayout(new GridLayout(3,2,2,2));
JLabel jl1 = new JLabel("用户名:");
JLabel jl2 = new JLabel("密码:");
JTextField jtf1 = new JTextField();
JTextField jtf2 = new JTextField();
jtf1.setSize(200, 40);
jtf2.setSize(200, 40);
c.add(jl1);
c.add(jtf1);
c.add(jl2);
c.add(jtf2);
c.add(new JButton("登入"));
jf.setVisible(true);
jf.setSize(300, 100);
jf.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
}
}
求Java编的登录界面代码:登录后分别进入管理员界面及用户界面 , 依据是数据库中的用户名和密码分三个包,自己建个包,导进去就ok了 , 数据库是access的 。
package 登录;
import java.awt.EventQueue;
public class Cilent {
private JFrame frame;
private JTextField textField;
private JPasswordField passwordField;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Cilent window = new Cilent();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Cilent() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setTitle("登陆界面");
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
frame.setResizable(false);
JLabel lblNewLabel = new JLabel("用户名");
lblNewLabel.setBounds(38, 43, 80, 34);
frame.getContentPane().add(lblNewLabel);
textField = new JTextField();
textField.setBounds(155, 42, 227, 37);
frame.getContentPane().add(textField);
textField.setColumns(10);
JLabel label = new JLabel("密 码");
label.setBounds(38, 115, 80, 34);
frame.getContentPane().add(label);
passwordField = new JPasswordField();
passwordField.setBounds(155, 115, 227, 37);
frame.getContentPane().add(passwordField);
JButton btnNewButton = new JButton("登 录");
btnNewButton.setBounds(60, 187, 115, 34);
frame.getContentPane().add(btnNewButton);
btnNewButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
UserCheck UC=new UserCheck(textField.getText(),String.valueOf(passwordField.getPassword()));
if(UC.getI()!=0)//有此用户
{
frame.setVisible(false);
}
else
{
textField.setText("");
passwordField.setText("");
}
}
});
JButton button = new JButton("取 消");

推荐阅读