最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
實現(xiàn)登錄注冊java代碼 java實現(xiàn)登陸注冊

java語言實現(xiàn)用戶注冊和登錄

//這個是我寫的,里面有連接數(shù)據(jù)庫的部分。你可以拿去參考一下

創(chuàng)新互聯(lián)專注于蘿北網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供蘿北營銷型網(wǎng)站建設(shè),蘿北網(wǎng)站制作、蘿北網(wǎng)頁設(shè)計、蘿北網(wǎng)站官網(wǎng)定制、微信平臺小程序開發(fā)服務(wù),打造蘿北網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供蘿北網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.sql.*;

class LoginFrm extends JFrame implements ActionListener// throws Exception

{

JLabel lbl1 = new JLabel("用戶名:");

JLabel lbl2 = new JLabel("密碼:");

JTextField txt = new JTextField(5);

JPasswordField pf = new JPasswordField();

JButton btn1 = new JButton("確定");

JButton btn2 = new JButton("取消");

public LoginFrm() {

this.setTitle("登陸");

JPanel jp = (JPanel) this.getContentPane();

jp.setLayout(new GridLayout(3, 2, 5, 5));

jp.add(lbl1);

jp.add(txt);

jp.add(lbl2);

jp.add(pf);

jp.add(btn1);

jp.add(btn2);

btn1.addActionListener(this);

btn2.addActionListener(this);

}

public void actionPerformed(ActionEvent ae) {

if (ae.getSource() == btn1) {

try {

Class.forName("com.mysql.jdbc.Driver");// mysql數(shù)據(jù)庫

Connection con = DriverManager.getConnection(

"jdbc:mysql://localhost/Car_zl", "root", "1");// 數(shù)據(jù)庫名為Car_zl,密碼為1

System.out.println("com : "+ con);

Statement cmd = con.createStatement();

String sql = "select * from user where User_ID='"

+ txt.getText() + "' and User_ps='"

+ pf.getText() + "'" ;

ResultSet rs = cmd

.executeQuery(sql);// 表名為user,user_ID和User_ps是存放用戶名和密碼的字段名

if (rs.next()) {

JOptionPane.showMessageDialog(null, "登陸成功!");

} else

JOptionPane.showMessageDialog(null, "用戶名或密碼錯誤!");

} catch (Exception ex) {

}

if (ae.getSource() == btn2) {

System.out.println("1111111111111");

//txt.setText("");

//pf.setText("");

System.exit(0);

}

}

}

public static void main(String arg[]) {

JFrame.setDefaultLookAndFeelDecorated(true);

LoginFrm frm = new LoginFrm();

frm.setSize(400, 200);

frm.setVisible(true);

}

}

用Java編寫注冊登錄程序

什么都不說了 直接給你代碼吧

package com.moliying.ui;

import java.awt.BorderLayout;

import java.awt.Container;

import java.awt.FlowLayout;

import java.awt.List;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedWriter;

import java.io.FileOutputStream;

import java.io.OutputStreamWriter;

import java.util.ArrayList;

import java.util.Arrays;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class Login {

private JFrame frame = new JFrame("登錄");

private Container c = frame.getContentPane();

private JTextField username = new JTextField();

private JPasswordField password = new JPasswordField();

private JButton ok = new JButton("確定");

private JButton cancel = new JButton("取消");

public Login() {

frame.setSize(300, 200);

frame.setBounds(450, 300, 300, 200);

c.setLayout(new BorderLayout());

initFrame();

frame.setVisible(true);

}

private void initFrame() {

// 頂部

JPanel titlePanel = new JPanel();

titlePanel.setLayout(new FlowLayout());

titlePanel.add(new JLabel("系統(tǒng)管理員登錄"));

c.add(titlePanel, "North");

// 中部表單

JPanel fieldPanel = new JPanel();

fieldPanel.setLayout(null);

JLabel a1 = new JLabel("用戶名:");

a1.setBounds(50, 20, 50, 20);

JLabel a2 = new JLabel("密 碼:");

a2.setBounds(50, 60, 50, 20);

fieldPanel.add(a1);

fieldPanel.add(a2);

username.setBounds(110, 20, 120, 20);

password.setBounds(110, 60, 120, 20);

fieldPanel.add(username);

fieldPanel.add(password);

c.add(fieldPanel, "Center");

// 底部按鈕

JPanel buttonPanel = new JPanel();

buttonPanel.setLayout(new FlowLayout());

buttonPanel.add(ok);

buttonPanel.add(cancel);

c.add(buttonPanel, "South");

ok.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

System.out.println(username.getText().toString());

}

});

cancel.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

frame.setVisible(false);

}

});

}

public static void main(String[] args) {

// new Login();

String ss = "abbabbbaabbbccba";

System.out.println(ss.split("b").length);

}

}

用java編程實現(xiàn)用戶注冊并進行登錄操作

String username = "",password = "",passwordagain = ""; // 定義用戶名和密碼

將該變量等于為全局變量 或局部變量即可

java編寫一個登陸和注冊信息的源代碼,最簡單的就可以,不需要數(shù)據(jù)庫的那種

你這個不用數(shù)據(jù)庫真的是有點難搞

我寫了個用集合存儲的,你看看,能否幫上你

java.util.ListString?list?=?new?ArrayListString();

list.add("qq=123");//存儲的時候用(用戶名=密碼)的形式

list.add("ww=456");

String?username?=?"qq";

String?password?=?"123";

for?(int?i?=?0;?i??list.size();?i++)?{

String?num?=?username?+"="+password;

if(num.equals(list.get(i))){

System.out.println("登錄成功");

break;

}

}


網(wǎng)站欄目:實現(xiàn)登錄注冊java代碼 java實現(xiàn)登陸注冊
本文來源:http://fisionsoft.com.cn/article/doddihd.html