java用戶注冊 (我要源代碼)

跑這兒作家庭作業了? 如果連用哪種頁面技術都不知道提的話,恐怕別人給你源代碼你也看不懂哦,想想別人給你個tapestry、Wicket之類的寫的代碼,拿給老師肯定挨批的喲(一看就露餡了)。

㈡ 如何用Java編寫用戶注冊界面

界面建議用可視化來做,美觀且便捷。下面這個是完全用代碼寫的,僅供參考。
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.sql.*;
public class Register extends JFrame {
JLabel jl1 = new JLabel("用戶名");
JTextField jt1 = new JTextField();
JLabel jl2 = new JLabel("郵箱");
JTextField jt2 = new JTextField();
JLabel jl3 = new JLabel("密碼");
JPasswordField jpw1 = new JPasswordField();
JLabel jl4 = new JLabel("密碼確認");
JPasswordField jpw2 = new JPasswordField();
JButton register = new JButton("注冊");
JButton clean = new JButton("清空");
public Register(){
setLayout(new GridLayout(5,2));
add(jl1);
add(jt1);
add(jl2);
add(jt2);
add(jl3);
add(jpw1);
add(jl4);
add(jpw2);
add(register);
add(clean);
String name = jt1.getText();
String email = jt2.getText();
String pw = jpw1.getText();
register.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/db","root","");
Statement sta = con.createStatement();
sta.executeUpdate("INSERT INTO register VALUES(name,email,pw)");
JOptionPane.showMessageDialog(null,"注冊成功","提示",JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception ex){
ex.getStackTrace();
}
}
});
clean.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jt1.setText("");
jt2.setText("");
jpw1.setText("");
jpw2.setText("");
}
});
}
public static void main(String[] args){
Register frame = new Register();
frame.setTitle("用戶注冊");
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setVisible(true);
}
}

㈢ 求一個java注冊登錄的完整代碼

public class Test extends JFrame
{
UserCertification uc;
String url;
Connection con;
public Test(String title)
{
setTitle(title);
uc=new UserCertification();
Container c=getContentPane();
c.setLayout(new BorderLayout());
c.add(uc,BorderLayout.CENTER);
setSize(400,250);
try
{
url="jdbc:odbc:aaa";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection(url);
uc.jtusername.setText("恭喜!資料庫連接成功!");
}
catch(Exception e)
{
e.printStackTrace();
}
show();
}
public static void main(String args[])
{
Test test=new Test("登錄界面");
test.addWindowListener(new MyWindowListener());
}
}
class UserCertification extends JPanel
{

㈣ 用JAVA編寫一個用戶或注冊登錄界面。請哪位高手能夠寫下具體的代碼,謝謝

  1. 效果圖

    html"><!DOCTYPEhtml>
    <html>
    <head>
    <metacharset="UTF-8">
    <title>先鋒圖書館管理系統-登錄</title>
    <style>
    *{
    margin:0;
    padding:0;
    list-style:none;
    }
    #top{
    width:1000px;
    height:95px;
    margin:0auto;
    margin-top:25px;
    }
    #top_top{
    width:1000px;
    height:65px;
    background:deepskyblue;
    }
    #top_top_left{
    width:300px;
    height:65px;
    float:left;
    }
    #top_top_left>label{
    width:200px;
    height:65px;
    color:white;
    float:right;
    }
    #top_top_left>#a2{
    padding-left:10px;
    padding-top:20px;
    font-size:16px;
    }
    #top_bottom{
    width:1000px;
    height:30px;
    }
    #top_bottom_left{
    width:340px;
    height:30px;
    line-height:30px;
    font-size:12px;
    background:skyblue;
    color:white;
    text-indent:2em;
    float:left;
    }
    #top_bottom_right{
    width:660px;
    height:30px;
    line-height:30px;
    font-size:12px;
    color:blueviolet;
    text-align:center;
    float:right;
    background:lightskyblue;
    }
    #content{
    width:1000px;
    height:600px;
    margin:0auto;
    background:#587FBA;
    }
    #content>#text{
    width:1000px;
    height:50px;
    line-height:50px;
    padding-top:100px;
    font-size:36px;
    font-family:"楷體";
    font-weight:bold;
    text-align:center;
    }
    #content>#login{
    width:480px;
    height:210px;
    margin-top:20px;
    margin-left:260px;
    background:#85A0CB;
    }
    #content>#login>img{
    float:left;
    }
    #content>#login>#select{
    width:305px;
    height:210px;
    float:right;
    }
    #content>#login>#select>div{
    width:230;
    height:30px;
    margin-left:30px;
    }
    #content>#login>#select>#d1{
    margin-top:30px;
    margin-bottom:3px;
    }
    #content>#login>#select>p{
    font-size:14px;
    margin-left:95px;
    }
    #bottom{
    width:1000px;
    height:35px;
    line-height:35px;
    margin:0auto;
    background:deepskyblue;
    text-align:center;
    color:white;
    }
    </style>
    </head>
    <body>
    <divid="top">
    <divid="top_top">
    <divid="top_top_left">
    <imgsrc="img/test/a13.png"width="78px"height="65px"><labelid="a2">先鋒圖書館系統管理平台</label>
    </div>
    </div>
    <divid="top_bottom">
    <divid="top_bottom_left">當前位置:首頁>系統管理>登錄</div>
    <divid="top_bottom_right">當前時間:<labelid="lable"></label></div>
    </div>
    </div>
    <divid="content">
    <divid="text">歡迎登錄先鋒圖書館管理系統</div>
    <divid="login">
    <imgsrc="img/test/a14.png"width="175px"height="210px"/>
    <formid="select">
    <divid="d1">用戶名:&nbsp;&nbsp;<inputtype="text"/></div>
    <div>密&nbsp;碼:&nbsp;&nbsp;<inputtype="password"/></div>
    <p>
    <inputtype="radio"name="user"value="read"/>讀者&nbsp;&nbsp;&nbsp;&nbsp;
    <inputtype="radio"name="user"value="admin"/>管理員
    </p><br/>
    <p>
    <inputtype="button"value="確定"style="width:50px;"onclick="put()"/>&nbsp;&nbsp;&nbsp;&nbsp;
    <inputtype="reset"value="重置"style="width:50px;"/>
    </p>
    </form>
    </div>
    </div>
    <divid="bottom">欣欣科技有限公司版權所有</div>
    </body>
    <scripttype="text/javascript"src="JQuery/jquery.js"></script>
    <scripttype="text/javascript"src="js/GetCurrentTime.js"></script>
    <script>
    //驗證用戶名和密碼
    functionput(){
    vard=$("#select>div>input");//獲取用戶名和密碼
    varname=d[0].value;
    varpass=d[1].value;
    varuser=null;
    varr=document.getElementsByName("user");//獲取用戶類型
    for(i=0;i<r.length;i++){
    if(r[i].checked){
    user=r[i].value;
    }
    }
    //console.log(name+","+pass+","+user);//輸出測試
    if(user==null){
    window.alert("請選擇用戶類型!");
    }elseif(user=="admin"&&name!="admin"){
    window.alter("用戶名錯誤!");
    }elseif(user=="admin"&&name=="admin"&&pass!="123456"){
    window.alert("密碼錯誤!");
    }elseif(name=="admin"&&pass=="123456"&&user=="admin"){
    window.location.href="work_02_welcome.html";//在js中在本頁面中打開新鏈接
    }else{
    window.alert("用戶名錯誤");
    }
    }
    </script>
    </html>

㈤ java編寫一個登陸和注冊信息的源代碼,最簡單的就可以,不需要資料庫的那種

。。。不需要資料庫,還要進行存儲,好吧,我還真沒這么嘗試過,這是要存儲為txt文件么⊙﹏⊙b。。。

㈥ java注冊頁面代碼

很簡單,
建一個叫student的對象,然後給他幾個屬性。
存在一個list里就行了,
登錄的時候就便利這個list,發現有一樣的,就給他進去,沒有就報錯。

你用可以存key和valu的容器也行。

㈦ 用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("系統管理員登錄"));
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編程實現用戶注冊並進行登錄操作

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

將該變數等於為全局變數 或局部變數即可

㈨ 用java寫界面注冊怎麼寫

package com.demo.client;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.*;public class RegistFrame extends JFrame implements ActionListener{
String serverIp = null;
int port = 0;
String strSex = "";
int PswProtectNum;
String area = "";
JLabel labUserId;
JLabel labChatname;
JLabel labPsw;
JLabel labRePsw;
JLabel labPswQst;
JLabel labPswAns;
JLabel labAge;
JLabel labArea;
JLabel labSex;
JTextField txtUserID;
JTextField txtChatname;
JPasswordField txtPsw;
JPasswordField txtRePsw;
JComboBox comPswQst;
JTextField txtPswAns;
JTextField txtAge;
JComboBox comArea;
JRadioButton rad1,rad2,rad3;
JButton btnSubmit;
JButton btnCancel;
JPanel p0,p1,p3,p4,p5,p6,p7,p8,p9,p10;
ItemListener listener1 = new ItemListener() { public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
JRadioButton button = (JRadioButton)e.getItemSelectable();
if (button == rad1)strSex = "男";
if (button == rad2)strSex = "女";
if (button == rad3)strSex = "";
}
};
ItemListener listener2 = new ItemListener() { public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
JComboBox box = (JComboBox)e.getItemSelectable();
if(box == comPswQst){
PswProtectNum = comPswQst.getSelectedIndex();
}
if(box == comArea){
area = comArea.getSelectedItem().toString();
}
}
};
public RegistFrame(String serverIp,int port) {
this.serverIp = serverIp;
this.port = port;
p0 = new JPanel();
labUserId = new JLabel("*帳號:");
txtUserID = new JTextField(20);
txtUserID.setEditable(true);
p0.add(labUserId);
p0.add(txtUserID);
p1 = new JPanel();
labChatname = new JLabel("*昵稱:");
txtChatname = new JTextField(20);
txtChatname.setEditable(true);
p1.add(labChatname);
p1.add(txtChatname);
p3 = new JPanel();
labPsw = new JLabel("*請輸入密碼:");
txtPsw = new JPasswordField(20);
p3.add(labPsw);
p3.add(txtPsw);
p4 = new JPanel();
labRePsw = new JLabel("*請再次輸入密碼:");
txtRePsw = new JPasswordField(20);
p4.add(labRePsw);
p4.add(txtRePsw);
p5 = new JPanel();
labPswQst = new JLabel("請設定密碼保護問題:");
String [] strQst = {
"",
"您母親的姓名是?",
"您父親的職業是?",
"您配偶的生日是?",
"您的學號(工號)是?",
"您母親的生日是?",
"您高中班主任的姓名是?",
"您父親的姓名是?",
"您的出生地是?",
"您小學班主任的姓名是?",
"您配偶的姓名是?"
};
comPswQst = new JComboBox(strQst);
comPswQst.addItemListener(listener2);
p5.add(labPswQst);
p5.add(comPswQst);
p6 = new JPanel();
labPswAns = new JLabel("請設定密碼保護答案:");
txtPswAns = new JTextField(20);
p6.add(labPswAns);
p6.add(txtPswAns);
p7 = new JPanel();
labAge = new JLabel("您的性別是:");
rad1 = new JRadioButton("我是帥哥!");
rad1.addItemListener(listener1);
rad2 = new JRadioButton("我是美女!");
rad2.addItemListener(listener1);
rad3 = new JRadioButton("我不告訴你!");
rad3.addItemListener(listener1);
ButtonGroup group = new ButtonGroup();
group.add(rad1);
group.add(rad2);
group.add(rad3);
p7.add(labAge);
p7.add(rad1);
p7.add(rad2);
p7.add(rad3);
p8 = new JPanel();
labArea = new JLabel("請選擇您的地區:");
String [] strArea = {
"我是南方人",
"我是北方人",
"我是東北人",
"我是西北人",
"我是西南人"
};
comArea = new JComboBox(strArea);
comArea.addItemListener(listener2);
p8.add(labArea);
p8.add(comArea);
p9 = new JPanel();
labAge = new JLabel("您的年齡是:");
txtAge = new JTextField(15);
p9.add(labAge);
p9.add(txtAge);
p10 = new JPanel();
btnSubmit = new JButton("提交");
btnSubmit.addActionListener(this);
btnCancel = new JButton("取消");
btnCancel.addActionListener(this);
p10.add(btnSubmit);
p10.add(btnCancel);
getContentPane().setLayout(new GridLayout(10,1));
getContentPane().add(p0);
getContentPane().add(p1);
getContentPane().add(p3);
getContentPane().add(p4);
getContentPane().add(p5);
getContentPane().add(p6);
getContentPane().add(p7);
getContentPane().add(p8);
getContentPane().add(p9);
getContentPane().add(p10);
setTitle("注冊新用戶");
pack();
setResizable(false);
setDefaultCloseOperation(RegistFrame.DISPOSE_ON_CLOSE);
Toolkit tk=Toolkit.getDefaultToolkit();
setLocation((tk.getScreenSize().width-getSize().width)/2,(tk.getScreenSize().height-getSize().height)/2);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
JButton button1 = (JButton)e.getSource();
//JRadioButton button2 = (JRadioButton)e.getSource();
if(button1 == btnSubmit){
if(txtUserID.getText().length() == 0
|| txtChatname.getText().length() == 0
|| txtUserID.getText().length() == 0
|| txtPsw.getPassword().length == 0){
JOptionPane.showMessageDialog(null, "昵稱,用戶名,密碼都不能為空!",
"警告", JOptionPane.WARNING_MESSAGE);
}
else
if(!txtPsw.getText().equals(txtRePsw.getText())){
JOptionPane.showMessageDialog(null, "再次密碼輸入不一致!",
"警告", JOptionPane.WARNING_MESSAGE);
}
else {
addNewUser();
}
}
if(button1 == btnCancel){
dispose();
}
}
//處理注冊用戶
private void addNewUser(){
//代碼請自己編寫
}
public static void main(String []args){
new RegistFrame("127.0.0.1",2345);
}
}

㈩ java用戶注冊界面實現,下面代碼哪錯了呢

Exception in thread "main" java.lang.: 2
at wyf.jc.child.<init>(child.java:22)
at wyf.jc.child.main(child.java:66)
數組越界異常!!!好好檢查下
還有這一句 :
else if{
jlArray[4].setText("正在注冊中");

這個if後沒跟條件