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


String choujiang = input.next();
if (choujiang.equals("y")) {
int[] luckynumber = new int[5];
for (int m = 0; m5; m++) {
luckynumber[m] = output.nextInt(8999) + 1000;
}
for (int m = 0; m5; m++) {
System.out.print(luckynumber[m] + "\t");
}
System.out.println("\n" + number);
for (int m = 0; m5; m++) {
if (number == luckynumber[m]) {
System.out.println("\n中奖!金额为:" + luckynumber);
break;
} else {
System.out.println("\n木有中奖!");
break;
}
}
} else {
System.out.println("程序结束!");
break;
}
}
break;
default:
System.out.println("没有对应的菜单选项!请重试");
break;
}
System.out.println("是否继续(y/n)?");
str = input.next();
} while (str.equals("y"));
System.out.println("程序结束!");
}
}
给个代码 自己玩玩
java写的用户登陆实例,用eclipse开发的具体步奏和代码import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;import javax.swing.*;public class Login extends JFrame{
JLabel user,passwd;
JTextField userput;
JPasswordField passput;
JButton denglu,tuichu;
public Login(){
super("用户登录");
Container c=getContentPane();
c.setLayout(null);
Font f=new Font("宋体",Font.PLAIN,12);
user=new JLabel("账号");
passwd=new JLabel("密码");
userput=new JTextField();
passput=new JPasswordField();
denglu=new JButton("登录");
denglu.setFont(f);
denglu.addActionListener(new NewAction());
tuichu=new JButton("退出");
tuichu.setFont(f);
tuichu.addActionListener(new NewAction());
user.setBounds(50,50,60,20);
userput.setBounds(110,50,150,20);
passwd.setBounds(50,80,60,20);
passput.setBounds(110,80,150,20);
denglu.setBounds(50,160,60,30);
tuichu.setBounds(200,160,60,30);
c.add(user);
c.add(userput);
c.add(passwd);
c.add(passput);
c.add(denglu);
c.add(tuichu);
setSize(350, 300);
setVisible(true);
}
class NewAction implements ActionListener{
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=CDM";
String user="sa";
String passwd="394513265";
java.sql.Connection con;
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con= DriverManager.getConnection(url,user,passwd);
}catch(Exception ep){
JOptionPane.showMessageDialog(null, "加载驱动失败!");
}
if(e.getSource()==denglu){
Find();
}
if(e.getSource()==tuichu){
dispose();
}
}public void Find(){
String lk="select * from login";
try{
Statement sql=con.createStatement();
ResultSet rs=sql.executeQuery(lk);
while(rs.next()){
if(rs.getString(1).equals(userput.getText())rs.getString(2).equals(passput.getText()))
new MainClient();
else
JOptionPane.showMessageDialog(null, "用户名或密码错误");
}
rs.close();
}catch(SQLException p){
JOptionPane.showMessageDialog(null, p.getMessage());
}
}
}
public static void main(String[] args) {
Login l=new Login();
l.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
步骤就是建个工程 然后建个class
用JAVA编一个用户登录界面 , 用户必须输入账号密码才能进入简单代码如下,原本想用弹窗的,懒得写了:

推荐阅读