學(xué)生登錄java代碼 java web學(xué)生用戶登錄界面

用java編寫學(xué)生成績管理系統(tǒng),登陸界面有,用戶名,密碼,登陸,取消...

自己在改改

成都創(chuàng)新互聯(lián)是一家專注網(wǎng)站建設(shè)、網(wǎng)絡(luò)營銷策劃、微信小程序開發(fā)、電子商務(wù)建設(shè)、網(wǎng)絡(luò)推廣、移動(dòng)互聯(lián)開發(fā)、研究、服務(wù)為一體的技術(shù)型公司。公司成立十載以來,已經(jīng)為數(shù)千家成都混凝土攪拌站各業(yè)的企業(yè)公司提供互聯(lián)網(wǎng)服務(wù)?,F(xiàn)在,服務(wù)的數(shù)千家客戶與我們一路同行,見證我們的成長;未來,我們一起分享成功的喜悅。

import java.awt.Dimension;

import java.awt.Toolkit;

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.JOptionPane;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class Test26 {

public static void main(String[] args) {

final String userName = "abc";

final String passwrod = "111";

JFrame jFrame = new JFrame("登陸界面");

Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();

jFrame.setBounds(((int)dimension.getWidth() - 200) / 2, ((int)dimension.getHeight() - 300) / 2, 200, 150);

jFrame.setResizable(false);

jFrame.setLayout(null);

jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JLabel label1 = new JLabel("姓名");

label1.setBounds(10, 10, 100, 30);

jFrame.add(label1);

JLabel label2 = new JLabel("密碼");

label2.setBounds(10, 40, 100, 30);

jFrame.add(label2);

final JTextField text1 = new JTextField();

text1.setBounds(50, 15, 130, 20);

jFrame.add(text1);

final JPasswordField text2 = new JPasswordField();

text2.setBounds(50, 45, 130, 20);

jFrame.add(text2);

JButton button = new JButton("Login");

button.setBounds(10, 75, 170, 40);

button.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if(userName.equals(text1.getText()) passwrod.equals(text2.getText())) {

JOptionPane.showMessageDialog(null, "登陸成功", "提示", JOptionPane.INFORMATION_MESSAGE);

} else {

JOptionPane.showMessageDialog(null, "錯(cuò)誤", "提示", JOptionPane.ERROR_MESSAGE);

text1.setText("");

text2.setText("");

}

}

});

jFrame.add(button);

jFrame.setVisible(true);

}

}

登錄界面的java代碼,分別有教師登錄,管理員登錄,學(xué)生登錄,右邊是用戶名和密碼,見圖。

分三個(gè)包,自己建個(gè)包,導(dǎo)進(jìn)去就ok了,數(shù)據(jù)庫是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("取 消");

button.setBounds(242, 187, 115, 34);

frame.getContentPane().add(button);

button.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent arg0) {

// TODO Auto-generated method stub

textField.setText("");

passwordField.setText("");

}

});

}

}

/*****************************************************************/

package 登錄;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import 操作處理.UsersCL;

/**@author 20111024

* 檢測登錄的用戶在數(shù)據(jù)庫中有無,若沒有,則提示沒有此用戶,

* 若有,則判斷級(jí)別:普通用戶還是管理員。

*/

public class UserCheck {

private int i=0; //用戶級(jí)別:0不是用戶、1是管理員、2是普通用戶

UserCheck(String name ,String password)

{

String jdriver="sun.jdbc.odbc.JdbcOdbcDriver";

String connectDB="jdbc:odbc:Students";

Statement stmt=null;

ResultSet rs=null;

Connection con=null;

try {

Class.forName(jdriver);

con=DriverManager.getConnection(connectDB);

stmt=con.createStatement();

String query="select * from users where name='"+name+"' and passwd='"+password+"'";

rs=stmt.executeQuery(query);

if(rs.next())

{

//數(shù)據(jù)庫中有此用戶,訪問成功

i=Integer.parseInt(rs.getString(3));

UsersCL UL=new UsersCL(i);

}

else

{

i=0; //沒有用戶是默認(rèn)是0級(jí)

}

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public int getI() {

return i;

}

}

/********************************************************************************************/

package 操作處理;

import java.awt.EventQueue;

public class UsersCL implements ActionListener{

private JFrame frame;

private JTextField textField;

private JTextField textField_1;

private JTextField textField_2;

private JTextField textField_3;

private int i=0;

private JLabel label_3;

private JTextField textField_4;

public UsersCL(int i) {

this.i=i;

frame = new JFrame();

frame.setTitle("用戶處理界面");

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

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().setLayout(null);

frame.setResizable(false);

frame.setVisible(true);

JLabel lblNewLabel = new JLabel("學(xué) 號(hào)");

lblNewLabel.setBounds(24, 32, 74, 29);

frame.getContentPane().add(lblNewLabel);

JLabel label = new JLabel("姓 名");

label.setBounds(24, 71, 74, 29);

frame.getContentPane().add(label);

JLabel label_1 = new JLabel("年 齡");

label_1.setBounds(24, 110, 74, 29);

frame.getContentPane().add(label_1);

label_3 = new JLabel("性 別");

label_3.setBounds(24, 149, 74, 29);

frame.getContentPane().add(label_3);

JLabel label_2 = new JLabel("狀 態(tài)");

label_2.setBounds(24, 195, 74, 29);

frame.getContentPane().add(label_2);

textField = new JTextField();

textField.setBounds(101, 34, 113, 25);

frame.getContentPane().add(textField);

textField.setColumns(10);

textField_1 = new JTextField();

textField_1.setColumns(10);

textField_1.setBounds(101, 73, 113, 25);

frame.getContentPane().add(textField_1);

textField_2 = new JTextField();

textField_2.setColumns(10);

textField_2.setBounds(101, 112, 113, 25);

frame.getContentPane().add(textField_2);

textField_3 = new JTextField();

textField_3.setEditable(false);

textField_3.setColumns(10);

textField_3.setBounds(101, 199, 288, 25);

frame.getContentPane().add(textField_3);

textField_4 = new JTextField();

textField_4.setColumns(10);

textField_4.setBounds(101, 149, 113, 25);

frame.getContentPane().add(textField_4);

if(1==i)

{

JButton btnNewButton = new JButton("追 加");

btnNewButton.setBounds(276, 41, 113, 29);

frame.getContentPane().add(btnNewButton);

btnNewButton.addActionListener(this);

btnNewButton.setActionCommand("追加");

JButton button_1 = new JButton("刪 除");

button_1.setBounds(276, 145, 113, 29);

frame.getContentPane().add(button_1);

button_1.addActionListener(this);

button_1.setActionCommand("刪除");

}

JButton button = new JButton("查 詢");

button.setBounds(276, 91, 113, 29);

frame.getContentPane().add(button);

button.addActionListener(this);

button.setActionCommand("查詢");

}

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

String name,age,sex,query=null;

int num,age1,count=0;

num=Integer.parseInt(textField.getText());

name=textField_1.getText();

age1=Integer.parseInt(textField_2.getText());

sex=textField_4.getText();

if(e.getActionCommand().equals("追加"))

{

query="insert into students values("+num+","+"'"+name+"',"+age1+",'"+sex+"');";

count=1;

}

else if(e.getActionCommand().equals("查詢"))

{

query="select * from students where XSB="+num+";";

count=2;

}

else if(e.getActionCommand().equals("刪除"))

{

query="delete from students where XSB="+num+" and name="+"'"+name+"'";

count=3;

}

Statement stmt=null;

ResultSet rs=null;

Connection con=null;

String jdriver="sun.jdbc.odbc.JdbcOdbcDriver";

String connectDB="jdbc:odbc:Students";

String query1=null;

try {

Class.forName(jdriver);

con=DriverManager.getConnection(connectDB);

stmt=con.createStatement();

if(count==1)

{

query1="select * from students where XSB="+num+";";

rs=stmt.executeQuery(query1);

if(rs.next())

textField_3.setText("已經(jīng)由此記錄,不能追加!");

else

{

stmt.executeUpdate(query);

textField_3.setText("已經(jīng)追加完成!");

}

}

else if(2==count)

{

stmt.executeQuery(query);

rs=stmt.executeQuery(query);

if(rs.next())

{

textField_3.setText("已查找到此記錄!");

}

else

{

textField_3.setText("沒有此記錄,可以追加!");

}

}

else if(3==count)

{

query1="select * from students where XSB="+num+" and name="+"'"+name+"'";

rs=stmt.executeQuery(query1);

if(rs.next())

{

stmt.executeUpdate(query);

textField_3.setText("已刪除此記錄!");

}

else

textField_3.setText("無此記錄!");

}

} catch (ClassNotFoundException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (SQLException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

finally{

//關(guān)閉資源

if(stmt!=null){

try {

stmt.close();

} catch (Exception e2) {

// TODO: handle exception

}

stmt=null;

}

if(con!=null){

try {

con.close();

} catch (Exception e2) {

// TODO: handle exception

}

con=null;

}

}

}

}

java中做一個(gè)連接數(shù)據(jù)庫的學(xué)生教師登陸的界面,學(xué)生教師的 用戶名、密碼都是通過數(shù)據(jù)庫來訪問,

你可以做一個(gè)下拉框,選項(xiàng)有教師和學(xué)生,不過這個(gè)的話,一般是通過權(quán)限來控制的,這樣教師和學(xué)生登錄之后,看到的菜單就不一樣了。

JDBC連接數(shù)據(jù)庫

?創(chuàng)建一個(gè)以JDBC連接數(shù)據(jù)庫的程序,包含7個(gè)步驟:

1、加載JDBC驅(qū)動(dòng)程序:

在連接數(shù)據(jù)庫之前,首先要加載想要連接的數(shù)據(jù)庫的驅(qū)動(dòng)到JVM(Java虛擬機(jī)),

這通過java.lang.Class類的靜態(tài)方法forName(String className)實(shí)現(xiàn)。

例如:

try{

//加載MySql的驅(qū)動(dòng)類

Class.forName("com.mysql.jdbc.Driver") ;

}catch(ClassNotFoundException e){

System.out.println("找不到驅(qū)動(dòng)程序類 ,加載驅(qū)動(dòng)失敗!");

e.printStackTrace() ;

}

成功加載后,會(huì)將Driver類的實(shí)例注冊(cè)到DriverManager類中。

2、提供JDBC連接的URL

?連接URL定義了連接數(shù)據(jù)庫時(shí)的協(xié)議、子協(xié)議、數(shù)據(jù)源標(biāo)識(shí)。

?書寫形式:協(xié)議:子協(xié)議:數(shù)據(jù)源標(biāo)識(shí)

協(xié)議:在JDBC中總是以jdbc開始

子協(xié)議:是橋連接的驅(qū)動(dòng)程序或是數(shù)據(jù)庫管理系統(tǒng)名稱。

數(shù)據(jù)源標(biāo)識(shí):標(biāo)記找到數(shù)據(jù)庫來源的地址與連接端口。

例如:(MySql的連接URL)

jdbc:mysql:

//localhost:3306/test?useUnicode=truecharacterEncoding=gbk ;

useUnicode=true:表示使用Unicode字符集。如果characterEncoding設(shè)置為

gb2312或GBK,本參數(shù)必須設(shè)置為true 。characterEncoding=gbk:字符編碼方式。

3、創(chuàng)建數(shù)據(jù)庫的連接

?要連接數(shù)據(jù)庫,需要向java.sql.DriverManager請(qǐng)求并獲得Connection對(duì)象,

該對(duì)象就代表一個(gè)數(shù)據(jù)庫的連接。

?使用DriverManager的getConnectin(String url , String username ,

String password )方法傳入指定的欲連接的數(shù)據(jù)庫的路徑、數(shù)據(jù)庫的用戶名和

密碼來獲得。

例如:

//連接MySql數(shù)據(jù)庫,用戶名和密碼都是root

String url = "jdbc:mysql://localhost:3306/test" ;

String username = "root" ;

String password = "root" ;

try{

Connection con =

DriverManager.getConnection(url , username , password ) ;

}catch(SQLException se){

System.out.println("數(shù)據(jù)庫連接失??!");

se.printStackTrace() ;

}

4、創(chuàng)建一個(gè)Statement

?要執(zhí)行SQL語句,必須獲得java.sql.Statement實(shí)例,Statement實(shí)例分為以下3

種類型:

1、執(zhí)行靜態(tài)SQL語句。通常通過Statement實(shí)例實(shí)現(xiàn)。

2、執(zhí)行動(dòng)態(tài)SQL語句。通常通過PreparedStatement實(shí)例實(shí)現(xiàn)。

3、執(zhí)行數(shù)據(jù)庫存儲(chǔ)過程。通常通過CallableStatement實(shí)例實(shí)現(xiàn)。

具體的實(shí)現(xiàn)方式:

Statement stmt = con.createStatement() ;

PreparedStatement pstmt = con.prepareStatement(sql) ;

CallableStatement cstmt =

con.prepareCall("{CALL demoSp(? , ?)}") ;

5、執(zhí)行SQL語句

Statement接口提供了三種執(zhí)行SQL語句的方法:executeQuery 、executeUpdate

和execute

1、ResultSet executeQuery(String sqlString):執(zhí)行查詢數(shù)據(jù)庫的SQL語句

,返回一個(gè)結(jié)果集(ResultSet)對(duì)象。

2、int executeUpdate(String sqlString):用于執(zhí)行INSERT、UPDATE或

DELETE語句以及SQL DDL語句,如:CREATE TABLE和DROP TABLE等

3、execute(sqlString):用于執(zhí)行返回多個(gè)結(jié)果集、多個(gè)更新計(jì)數(shù)或二者組合的

語句。

具體實(shí)現(xiàn)的代碼:

ResultSet rs = stmt.executeQuery("SELECT * FROM ...") ;

int rows = stmt.executeUpdate("INSERT INTO ...") ;

boolean flag = stmt.execute(String sql) ;

6、處理結(jié)果

兩種情況:

1、執(zhí)行更新返回的是本次操作影響到的記錄數(shù)。

2、執(zhí)行查詢返回的結(jié)果是一個(gè)ResultSet對(duì)象。

? ResultSet包含符合SQL語句中條件的所有行,并且它通過一套get方法提供了對(duì)這些

行中數(shù)據(jù)的訪問。

? 使用結(jié)果集(ResultSet)對(duì)象的訪問方法獲取數(shù)據(jù):

while(rs.next()){

String name = rs.getString("name") ;

String pass = rs.getString(1) ; // 此方法比較高效

}

(列是從左到右編號(hào)的,并且從列1開始)

7、關(guān)閉JDBC對(duì)象

操作完成以后要把所有使用的JDBC對(duì)象全都關(guān)閉,以釋放JDBC資源,關(guān)閉順序和聲

明順序相反:

1、關(guān)閉記錄集

2、關(guān)閉聲明

3、關(guān)閉連接對(duì)象

if(rs != null){ // 關(guān)閉記錄集

try{

rs.close() ;

}catch(SQLException e){

e.printStackTrace() ;

}

}

if(stmt != null){ // 關(guān)閉聲明

try{

stmt.close() ;

}catch(SQLException e){

e.printStackTrace() ;

}

}

if(conn != null){ // 關(guān)閉連接對(duì)象

try{

conn.close() ;

}catch(SQLException e){

e.printStackTrace() ;

}

}

用java寫一個(gè)登陸界面代碼。

概述

具體框架使用jframe,文本框組件:JTextField;密碼框組件:JPasswordField;標(biāo)簽組件:JLabel;復(fù)選框組件:JCheckBox;單選框組件:JRadioButton;按鈕組件JButton。

登錄界面:

代碼實(shí)例

import javax.swing.*;

import java.awt.*; ? //導(dǎo)入必要的包

public class denglu extends JFrame{

JTextField jTextField ;//定義文本框組件

JPasswordField jPasswordField;//定義密碼框組件

JLabel jLabel1,jLabel2;

JPanel jp1,jp2,jp3;

JButton jb1,jb2; //創(chuàng)建按鈕

public denglu(){

jTextField = new JTextField(12);

jPasswordField = new JPasswordField(13);

jLabel1 = new JLabel("用戶名");

jLabel2 = new JLabel("密碼");

jb1 = new JButton("確認(rèn)");

jb2 = new JButton("取消");

jp1 = new JPanel();

jp2 = new JPanel();

jp3 = new JPanel();

//設(shè)置布局

this.setLayout(new GridLayout(3,1));

jp1.add(jLabel1);

jp1.add(jTextField);//第一塊面板添加用戶名和文本框

jp2.add(jLabel2);

jp2.add(jPasswordField);//第二塊面板添加密碼和密碼輸入框

jp3.add(jb1);

jp3.add(jb2); //第三塊面板添加確認(rèn)和取消

// ? ? ? ?jp3.setLayout(new FlowLayout()); ?//因?yàn)镴Panel默認(rèn)布局方式為FlowLayout,所以可以注銷這段代碼.

this.add(jp1);

this.add(jp2);

this.add(jp3); ?//將三塊面板添加到登陸框上面

//設(shè)置顯示

this.setSize(300, 200);

//this.pack();

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

this.setTitle("登陸");

}

public static void main(String[] args){

new denglu();

}

}

拓展內(nèi)容

java swing包

Swing 是一個(gè)為Java設(shè)計(jì)的GUI工具包。

Swing是JAVA基礎(chǔ)類的一部分。

Swing包括了圖形用戶界面(GUI)器件如:文本框,按鈕,分隔窗格和表。

Swing提供許多比AWT更好的屏幕顯示元素。它們用純Java寫成,所以同Java本身一樣可以跨平臺(tái)運(yùn)行,這一點(diǎn)不像AWT。它們是JFC的一部分。它們支持可更換的面板和主題(各種操作系統(tǒng)默認(rèn)的特有主題),然而不是真的使用原生平臺(tái)提供的設(shè)備,而是僅僅在表面上模仿它們。這意味著你可以在任意平臺(tái)上使用JAVA支持的任意面板。輕量級(jí)組件的缺點(diǎn)則是執(zhí)行速度較慢,優(yōu)點(diǎn)就是可以在所有平臺(tái)上采用統(tǒng)一的行為。

概念解析:

JFrame?– java的GUI程序的基本思路是以JFrame為基礎(chǔ),它是屏幕上window的對(duì)象,能夠最大化、最小化、關(guān)閉。

JPanel?– Java圖形用戶界面(GUI)工具包swing中的面板容器類,包含在javax.swing 包中,可以進(jìn)行嵌套,功能是對(duì)窗體中具有相同邏輯功能的組件進(jìn)行組合,是一種輕量級(jí)容器,可以加入到JFrame窗體中。。

JLabel?– JLabel 對(duì)象可以顯示文本、圖像或同時(shí)顯示二者??梢酝ㄟ^設(shè)置垂直和水平對(duì)齊方式,指定標(biāo)簽顯示區(qū)中標(biāo)簽內(nèi)容在何處對(duì)齊。默認(rèn)情況下,標(biāo)簽在其顯示區(qū)內(nèi)垂直居中對(duì)齊。默認(rèn)情況下,只顯示文本的標(biāo)簽是開始邊對(duì)齊;而只顯示圖像的標(biāo)簽則水平居中對(duì)齊。

JTextField?–一個(gè)輕量級(jí)組件,它允許編輯單行文本。

JPasswordField?– 允許我們輸入了一行字像輸入框,但隱藏星號(hào)(*) 或點(diǎn)創(chuàng)建密碼(密碼)

JButton?– JButton 類的實(shí)例。用于創(chuàng)建按鈕類似實(shí)例中的 "Login"。

java代碼

幫你改了一下:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class logon extends JFrame {

public static void main(String args[]) {

logon a=new logon();

a.show();

}

CheckboxGroup ShenFen=new CheckboxGroup();

Checkbox ShenFen1;

Checkbox ShenFen2;

Checkbox ShenFen3;

JButton LogonButton,Exit;

JTextField id;

JPasswordField password;

public logon(){

this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

this.setLayout(null);

setTitle("學(xué)生選課系統(tǒng)");

setSize(600,600);

ShenFen1=new Checkbox("學(xué)生",ShenFen,true);

ShenFen2=new Checkbox("教師",ShenFen,false);

ShenFen3=new Checkbox("管理員",ShenFen,false);

add(ShenFen1);

add(ShenFen2);

add(ShenFen3);

ShenFen1.setBounds(300, 350, 50, 50);

ShenFen2.setBounds(350, 350, 50, 50);

ShenFen3.setBounds(400, 350, 50, 50);

LogonButton=new JButton("登錄");

add(LogonButton);

Exit=new JButton("退出");

add(Exit);

Exit.setBounds(400, 400,60, 60);

id=new JTextField();

add(id);

id.setBounds(300, 200, 200, 30);

password=new JPasswordField();

add(password);

password.setBounds(300, 250, 200, 30);

}

}

JAVA編程如何實(shí)現(xiàn)一個(gè)學(xué)生信息管理系統(tǒng)登錄界面?

importjava.awt.*;\x0d\x0aimportjava.awt.event.*;\x0d\x0aimportjava.applet.*;\x0d\x0aimportjava.applet.Applet;\x0d\x0aimportjava.io.*;\x0d\x0aimportjavax.xml.parsers.DoumentBuilderFactory;\x0d\x0a\x0d\x0apublicclassUserPanelextendsAppletimplentsActionListener\x0d\x0a{\x0d\x0aLabellblName,lblNumber,lblSex,lblJob,lblText;\x0d\x0aTextFieletfName.tfNumber;\x0d\x0acheckboxchMale,chFemale;\x0d\x0aTextAreataText;\x0d\x0achoicechJob;\x0d\x0aButtonbtnOk,btnDisply;\x0d\x0aPanelp1,p2,p3,p4,p5,p6,p7,p8,p9;\x0d\x0aStringstrName,strNumber,strSex,strJob,strText;\x0d\x0a\x0d\x0apublicvoidinit()\x0d\x0a{\x0d\x0alblName=newLabel("姓名");\x0d\x0alblNumber=newLabel("身份證號(hào)");\x0d\x0alblSex=newLabel("性別");\x0d\x0alblJob=newLabel("職業(yè)");\x0d\x0alblText=newLabel("個(gè)性化宣言");\x0d\x0atfName=newTextField(23);\x0d\x0atfNumber=newTextFidle(20);\x0d\x0ataText=newTextArea(10,20);\x0d\x0ac=newcheckboxGroup();\x0d\x0achMale=newcheckbox("男",c,true);\x0d\x0achFemale=newcheckbox("女",c,false);\x0d\x0achJob=newchoice();\x0d\x0achJob.add("學(xué)生");\x0d\x0abtnOk=newButton("確定");\x0d\x0abtnDisplay=newButton("顯示");\x0d\x0ap1=newpanel();\x0d\x0ap2=newpanel();\x0d\x0ap3=newpanel();\x0d\x0ap4=newpanel();\x0d\x0ap5=newpanel();\x0d\x0ap6=newpanel();\x0d\x0ap7=newpanel(newBorderLayout());\x0d\x0ap8=newpanel();\x0d\x0ap9=newpanel(newBorderLayout());\x0d\x0a//\x0d\x0ap1.add(lblName);\x0d\x0ap1.add(tfName);\x0d\x0ap2.add(lblNumber);\x0d\x0ap2.add(lblNumber);\x0d\x0ap3.add(lblSex);\x0d\x0ap3.add(chMale);\x0d\x0ap3.add(chFemale);\x0d\x0ap4.add(lblJob);\x0d\x0ap4.add(chJob);\x0d\x0ap5.add(p3);\x0d\x0ap5.add(p4);\x0d\x0ap6.setLayout(newBorderLayout());\x0d\x0ap6.add(p1,BorderLayout.NORTH);\x0d\x0ap6.add(p2,BorderLayout.CENTER);\x0d\x0ap6.add(p5,BorderLayout.SOUTH);\x0d\x0ap7.add(lblText,BorderLayout.NORTH);\x0d\x0ap7.add(lblText,BorderLayout.CENTER);\x0d\x0ap8.setLayout(newFlowLayout(FlowLayout.CENTER,30,10));\x0d\x0ap8.add(btnOK);\x0d\x0ap8.add(btnDisplay);\x0d\x0ap9.add(p6,BorderLayout.NORTH);\x0d\x0ap9.add(p7,BorderLayout.CENTER);\x0d\x0ap9.add(p8,BorderLayout.SOUTH);\x0d\x0aadd(p9);\x0d\x0a//\x0d\x0abtnOK.addActionListener(this);\x0d\x0abtnDisplay.addActionListener(this);\x0d\x0abtnDisplay.setEnabled(false);\x0d\x0astrName=newString();\x0d\x0astrNumber=newString();\x0d\x0astrSex=newString();\x0d\x0astrJob=newString();\x0d\x0astrText=newString();\x0d\x0a}\x0d\x0a\x0d\x0apublicvoidactionPerformed(ActionEventevt)\x0d\x0a{\x0d\x0astringarg=evt.getActionCommand();\x0d\x0a//\x0d\x0aif(arg.equals("確定"))\x0d\x0a{\x0d\x0astrName=tfName.getText().trim();\x0d\x0astrNumber=tfNumber.getText().trim();\x0d\x0aif(chMale.getState())\x0d\x0astrSex="男";\x0d\x0aelse\x0d\x0astrSex="女";\x0d\x0astrJob=chJob.getselectedItem();\x0d\x0astrText=taText.getText().trim();\x0d\x0atry\x0d\x0a{\x0d\x0a//\x0d\x0aDoumentBuildFactorydbf=DocumentBuilderFactory.newInstance();\x0d\x0adb=dbf.newDocumentBuilder();\x0d\x0aDoumentdoc=db.newDoument();\x0d\x0a//\x0d\x0aElementroot=doc.CreateElement("UserDAta");\x0d\x0aElementeName=doc.createElement("Name");\x0d\x0aElementeNumber=doc.createElement("Number");\x0d\x0aElementeJob=doc.createElement("Job");\x0d\x0aElementeText=doc.createElement("Text");\x0d\x0a//\x0d\x0aroot.appendChild(eName);\x0d\x0aroot.appendChild(eNumber);\x0d\x0aroot.appendChild(eSex);\x0d\x0aroot.appendChild(eJob);\x0d\x0aroot.appendChild(eText);\x0d\x0a//\x0d\x0aeName.appendChild(doc.creatTextNode("\n"strName"\n"));\x0d\x0aeNumber.appendChild(doc.creatTextNode("\n"strNumber"\n"));\x0d\x0aeSex.appendChild(doc.creatTextNode("\n"strSex"\n"));\x0d\x0aeJob.appendChild(doc.creatTextNode("\n"strJob"\n"));\x0d\x0aeText.appendChild(doc.creatTextNode("\n"strText"\n"));\x0d\x0a//\x0d\x0aFilef=newFile("user.xml");\x0d\x0aFileOutputStreamfOut=newFileOutStream(f);\x0d\x0a//\x0d\x0afOut.write("

文章標(biāo)題:學(xué)生登錄java代碼 java web學(xué)生用戶登錄界面
網(wǎng)頁鏈接:http://muchs.cn/article44/doscdhe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、微信公眾號(hào)、營銷型網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)