成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

學生登錄界面java代碼 java設置學生管理登陸界面

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

import java.awt.*;

創(chuàng)新互聯(lián)建站長期為數(shù)千家客戶提供的網(wǎng)站建設服務,團隊從業(yè)經(jīng)驗10年,關注不同地域、不同群體,并針對不同對象提供差異化的產品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為洪湖企業(yè)提供專業(yè)的成都網(wǎng)站設計、成都網(wǎng)站制作,洪湖網(wǎng)站改版等技術服務。擁有10年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

import java.awt.event.*;

import java.applet.*;

import java.applet.Applet;

import java.io.*;

import javax.xml.parsers.DoumentBuilderFactory;

public class UserPanel extends Applet implents ActionListener

{

Label lblName,lblNumber,lblSex,lblJob,lblText;

TextFiele tfName.tfNumber;

checkbox chMale,chFemale;

TextArea taText;

choice chJob;

Button btnOk,btnDisply;

Panel p1,p2,p3,p4,p5,p6,p7,p8,p9;

String strName,strNumber,strSex,strJob,strText;

public void init()

{

lblName=new Label("姓名");

lblNumber=new Label("身份證號");

lblSex=new Label(" 性別");

lblJob=new Label(" 職業(yè)");

lblText=new Label("個性化宣言 ");

tfName=new TextField(23);

tfNumber =new TextFidle(20);

taText=new TextArea(10,20);

c=new checkboxGroup();

chMale =new checkbox("男",c,true);

chFemale =new checkbox("女",c,false);

chJob =new choice();

chJob.add("學生");

btnOk=new Button("確定");

btnDisplay=new Button("顯示 ");

p1=new panel();

p2=new panel();

p3=new panel();

p4=new panel();

p5=new panel();

p6=new panel();

p7=new panel(new BorderLayout());

p8=new panel();

p9=new panel(new BorderLayout());

//

p1.add(lblName);

p1.add(tfName);

p2.add(lblNumber);

p2.add(lblNumber);

p3.add(lblSex);

p3.add(chMale);

p3.add(chFemale);

p4.add(lblJob);

p4.add(chJob);

p5.add(p3);

p5.add(p4);

p6.setLayout(new BorderLayout());

p6.add(p1,BorderLayout.NORTH);

p6.add(p2,BorderLayout.CENTER);

p6.add(p5,BorderLayout.SOUTH);

p7.add(lblText,BorderLayout.NORTH);

p7.add(lblText,BorderLayout.CENTER);

p8.setLayout(new FlowLayout(FlowLayout.CENTER,30,10));

p8.add(btnOK);

p8.add(btnDisplay);

p9.add(p6,BorderLayout.NORTH);

p9.add(p7,BorderLayout.CENTER);

p9.add(p8,BorderLayout.SOUTH);

add(p9);

//

btnOK.addActionListener(this);

btnDisplay.addActionListener(this);

btnDisplay.setEnabled(false);

strName=new String();

strNumber=new String();

strSex=new String();

strJob=new String();

strText=new String();

}

public void actionPerformed(ActionEvent evt)

{

string arg =evt.getActionCommand();

//

if(arg.equals("確定"))

{

strName=tfName.getText().trim();

strNumber=tfNumber.getText().trim();

if(chMale.getState() )

strSex="男";

else

strSex="女";

strJob=chJob.getselectedItem();

strText=taText.getText().trim();

try

{

//

DoumentBuildFactory dbf=DocumentBuilderFactory.newInstance();

db=dbf.newDocumentBuilder();

Doument doc=db.newDoument();

//

Element root=doc.CreateElement("UserDAta");

Element eName=doc.createElement("Name");

Element eNumber=doc.createElement("Number");

Element eJob=doc.createElement("Job");

Element eText=doc.createElement("Text");

//

root.appendChild(eName);

root.appendChild(eNumber);

root.appendChild(eSex);

root.appendChild(eJob);

root.appendChild(eText);

//

eName.appendChild(doc.creatTextNode("\n" strName "\n") );

eNumber.appendChild(doc.creatTextNode("\n" strNumber "\n") );

eSex.appendChild(doc.creatTextNode("\n" strSex "\n") );

eJob.appendChild(doc.creatTextNode("\n" strJob "\n") );

eText.appendChild(doc.creatTextNode("\n" strText "\n") );

//

File f=new File("user.xml");

FileOutputStream fOut=new FileOutStream(f);

//

fOut.write("

如何用java做登錄界面

import javax.swing.JFrame;//框架

import javax.swing.JPanel;//面板

import javax.swing.JButton;//按鈕

import javax.swing.JLabel;//標簽

import javax.swing.JTextField;//文本框

import java.awt.Font;//字體

import java.awt.Color;//顏色

import javax.swing.JPasswordField;//密碼框

import java.awt.event.ActionListener;//事件監(jiān)聽

import java.awt.event.ActionEvent;//事件處理

import javax.swing.JOptionPane;//消息窗口public class UserLogIn extends JFrame{

public JPanel pnluser;

public JLabel lbluserLogIn;

public JLabel lbluserName;

public JLabel lbluserPWD;

public JTextField txtName;

public JPasswordField pwdPwd;

public JButton btnSub;

public JButton btnReset;

public UserLogIn(){

pnluser = new JPanel();

lbluserLogIn = new JLabel();

lbluserName = new JLabel();

lbluserPWD = new JLabel();

txtName = new JTextField();

pwdPwd = new JPasswordField();

btnSub = new JButton();

btnReset = new JButton();

userInit();

}

public void userInit(){

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//設置關閉框架的同時結束程序

this.setSize(300,200);//設置框架大小為長300,寬200

this.setResizable(false);//設置框架不可以改變大小

this.setTitle("用戶登錄");//設置框架標題

this.pnluser.setLayout(null);//設置面板布局管理

this.pnluser.setBackground(Color.cyan);//設置面板背景顏色

this.lbluserLogIn.setText("用戶登錄");//設置標簽標題

this.lbluserLogIn.setFont(new Font("宋體",Font.BOLD | Font.ITALIC,14));//設置標簽字體

this.lbluserLogIn.setForeground(Color.RED);//設置標簽字體顏色

this.lbluserName.setText("用戶名:");

this.lbluserPWD.setText("密 碼:");

this.btnSub.setText("登錄");

this.btnReset.setText("重置");

this.lbluserLogIn.setBounds(120,15,60,20);//設置標簽x坐標120,y坐標15,長60,寬20

this.lbluserName.setBounds(50,55,60,20);

this.lbluserPWD.setBounds(50,85,60,25);

this.txtName.setBounds(110,55,120,20);

this.pwdPwd.setBounds(110,85,120,20);

this.btnSub.setBounds(85,120,60,20);

this.btnSub.addActionListener(new ActionListener()//匿名類實現(xiàn)ActionListener接口

{

public void actionPerformed(ActionEvent e){

btnsub_ActionEvent(e);

}

}

);

this.btnReset.setBounds(155,120,60,20);

this.btnReset.addActionListener(new ActionListener()//匿名類實現(xiàn)ActionListener接口

{

public void actionPerformed(ActionEvent e){

btnreset_ActionEvent(e);

}

}

);

this.pnluser.add(lbluserLogIn);//加載標簽到面板

this.pnluser.add(lbluserName);

this.pnluser.add(lbluserPWD);

this.pnluser.add(txtName);

this.pnluser.add(pwdPwd);

this.pnluser.add(btnSub);

this.pnluser.add(btnReset);

this.add(pnluser);//加載面板到框架

this.setVisible(true);//設置框架可顯

}

public void btnsub_ActionEvent(ActionEvent e){

String name = txtName.getText();

String pwd = String.valueOf(pwdPwd.getPassword());

if(name.equals("")){

JOptionPane.showMessageDialog(null,"賬號不能為空","錯誤",JOptionPane.ERROR_MESSAGE);

return;

}else if (pwd.equals("")){

JOptionPane.showMessageDialog(null,"密碼不能為空","錯誤",JOptionPane.ERROR_MESSAGE);

return;

}else if(true){

this.dispose();

}else{

JOptionPane.showMessageDialog(null,"賬號或密碼錯誤","錯誤",JOptionPane.ERROR_MESSAGE);

return;

}

}

public void btnreset_ActionEvent(ActionEvent e){

txtName.setText("");

pwdPwd.setText("");

}

public static void main(String[] args){

new UserLogIn();

}

}

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

分三個包,自己建個包,導進去就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ù)庫中有無,若沒有,則提示沒有此用戶,

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

*/

public class UserCheck {

private int i=0; //用戶級別: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; //沒有用戶是默認是0級

}

} 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("學 號");

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{

//關閉資源

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代碼 java設置學生管理登陸界面
分享路徑:http://jinyejixie.com/article10/dosshdo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、ChatGPT搜索引擎優(yōu)化、品牌網(wǎng)站制作電子商務、App開發(fā)

廣告

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

成都網(wǎng)站建設
布拖县| 兴海县| 扎鲁特旗| 互助| 台北市| SHOW| 盐池县| 宁陕县| 南部县| 竹山县| 苏尼特左旗| 康乐县| 竹溪县| 屏东市| 南川市| 房产| 云南省| 包头市| 东兴市| 昌江| 永新县| 车险| 密山市| 天峨县| 刚察县| 花莲县| 黄骅市| 北京市| 河曲县| 金华市| 江山市| 海兴县| 前郭尔| 凤冈县| 潼南县| 安福县| 普兰店市| 夏津县| 桐乡市| 榆树市| 巴中市|