内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

關(guān)于java信息添加系統(tǒng)代碼的信息

用java編寫學(xué)生信息管理系統(tǒng)

僅僅給你個(gè)參考

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名與空間、虛擬空間、營銷軟件、網(wǎng)站建設(shè)、公安網(wǎng)站維護(hù)、網(wǎng)站推廣。

//Java Group Project_StudentManagement源碼

//NetBeans IDE 6.5 環(huán)境

package studentmanager;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.io.*;

import java.util.*;

class Student implements java.io.Serializable{

String number,name,specialty,grade,borth,sex;

public Student(){};

public void setNumber(String number)

public String getNumber()

public void setName(String name)

public String getName()

public void setSex(String sex)

public String getSex()

public void setSpecialty(String specialty)

public String getSpecialty()

public void setGrade(String grade)

public String getGrade()

public void setBorth(String borth)

public String getBorth()

}

public class StudentManager extends JFrame{

JLabel lb=new JLabel("錄入請(qǐng)先輸入記錄,查詢、刪除請(qǐng)先輸入學(xué)號(hào),修改是對(duì)查詢" +

"內(nèi)容改后的保存!");

JTextField 學(xué)號(hào),姓名,專業(yè),年級(jí),出生;

JRadioButton 男,女;

ButtonGroup group=null;

JButton 錄入,查詢,刪除,修改,顯示;

JPanel p1,p2,p3,p4,p5,p6,pv,ph;

Student 學(xué)生=null;

Hashtable 學(xué)生散列表=null;

File file=null;

FileInputStream inOne=null;

ObjectInputStream inTwo=null;

FileOutputStream outOne=null;

ObjectOutputStream outTwo=null;

public StudentManager(){

super("學(xué)生基本信息管理系統(tǒng)");

學(xué)號(hào)=new JTextField(10);

姓名=new JTextField(10);

專業(yè)=new JTextField(10);

年級(jí)=new JTextField(10);

出生=new JTextField(10);

group=new ButtonGroup();

男=new JRadioButton("男",true);

女=new JRadioButton("女",false);

group.add(男);

group.add(女);

錄入=new JButton("錄入");

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

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

修改=new JButton("修改");

顯示=new JButton("顯示");

錄入.addActionListener(new InputAct());

查詢.addActionListener(new InquestAct());

修改.addActionListener(new ModifyAct());

刪除.addActionListener(new DeleteAct());

顯示.addActionListener(new ShowAct());

修改.setEnabled(false);

p1=new JPanel();

p1.add(new JLabel("學(xué)號(hào):",JLabel.CENTER));

p1.add(學(xué)號(hào));

p2=new JPanel();

p2.add(new JLabel("姓名:",JLabel.CENTER));

p2.add(姓名);

p3=new JPanel();

p3.add(new JLabel("性別:",JLabel.CENTER));

p3.add(男);

p3.add(女);

p4=new JPanel();

p4.add(new JLabel("專業(yè):",JLabel.CENTER));

p4.add(專業(yè));

p5=new JPanel();

p5.add(new JLabel("年級(jí):",JLabel.CENTER));

p5.add(年級(jí));

p6=new JPanel();

p6.add(new JLabel("出生:",JLabel.CENTER));

p6.add(出生);

pv=new JPanel();

pv.setLayout(new GridLayout(6,1));

pv.add(p1);

pv.add(p2);

pv.add(p3);

pv.add(p4);

pv.add(p5);

pv.add(p6);

ph=new JPanel();

ph.add(錄入);

ph.add(查詢);

ph.add(修改);

ph.add(刪除);

ph.add(顯示);

file=new File("學(xué)生信息.txt");

學(xué)生散列表=new Hashtable();

if(!file.exists()){

try{

FileOutputStream out=new FileOutputStream(file);

ObjectOutputStream objectOut=new ObjectOutputStream(out);

objectOut.writeObject(學(xué)生散列表);

objectOut.close();

out.close();

}

catch(IOException e){}

}

Container con=getContentPane();

con.setLayout(new BorderLayout());

con.add(lb, BorderLayout.NORTH);

con.add(pv, BorderLayout.CENTER);

con.add(ph, BorderLayout.SOUTH);

setDefaultCloseOperation(EXIT_ON_CLOSE);

setBounds(100,100,600,300);

setVisible(true);

}

public static void main(String[] args)

class InputAct implements ActionListener{

public void actionPerformed(ActionEvent e){

修改.setEnabled(false);

String number="";

number=學(xué)號(hào).getText();

if(number.length()0){

try{

inOne=new FileInputStream(file);

inTwo=new ObjectInputStream(inOne);

學(xué)生散列表=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee)

if(學(xué)生散列表.containsKey(number)){

String warning="該生信息已存在,請(qǐng)到修改頁面修改!";

JOptionPane.showMessageDialog(null,warning,"警告",

JOptionPane.WARNING_MESSAGE);

}//end if1

else{

String m="該生信息將被錄入!";

int ok=JOptionPane.showConfirmDialog(null,m,"確認(rèn)",

JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);

if(ok==JOptionPane.YES_OPTION){

String name=姓名.getText();

String specialty=專業(yè).getText();

String grade=年級(jí).getText();

String borth=出生.getText();

String sex=null;

if(男.isSelected())

else

學(xué)生=new Student();

學(xué)生.setNumber(number);

學(xué)生.setName(name);

學(xué)生.setSpecialty(specialty);

學(xué)生.setGrade(grade);

學(xué)生.setBorth(borth);

學(xué)生.setSex(sex);

try{

outOne=new FileOutputStream(file);

outTwo=new ObjectOutputStream(outOne);

學(xué)生散列表.put(number,學(xué)生);

outTwo.writeObject(學(xué)生散列表);

outTwo.close();

outOne.close();

}

catch(Exception ee)

學(xué)號(hào).setText(null);

姓名.setText(null);

專業(yè).setText(null);

年級(jí).setText(null);

出生.setText(null);

}

}//end else1

}//end if0

else{

String warning="必須輸入學(xué)號(hào)!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}//end else0

}//end actionPerformed

}//end class

class InquestAct implements ActionListener{

public void actionPerformed(ActionEvent e){

String number="";

number=學(xué)號(hào).getText();

if(number.length()0){

try{

inOne=new FileInputStream(file);

inTwo=new ObjectInputStream(inOne);

學(xué)生散列表=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee)

if(學(xué)生散列表.containsKey(number)){

修改.setEnabled(true);

Student stu=(Student)學(xué)生散列表.get(number);

姓名.setText(stu.getName());

專業(yè).setText(stu.getSpecialty());

年級(jí).setText(stu.getGrade());

出生.setText(stu.getBorth());

if(stu.getSex().equals("男"))

else

}

else{

修改.setEnabled(false);

String warning="該學(xué)號(hào)不存在!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}

}

else{

修改.setEnabled(false);

String warning="必須輸入學(xué)號(hào)!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}

}

}

class ModifyAct implements ActionListener{

public void actionPerformed(ActionEvent e){

String number=學(xué)號(hào).getText();

String name=姓名.getText();

String specialty=專業(yè).getText();

String grade=年級(jí).getText();

String borth=出生.getText();

String sex=null;

if(男.isSelected())

else

Student 學(xué)生=new Student();

學(xué)生.setNumber(number);

學(xué)生.setName(name);

學(xué)生.setSpecialty(specialty);

學(xué)生.setGrade(grade);

學(xué)生.setBorth(borth);

學(xué)生.setSex(sex);

try{

outOne=new FileOutputStream(file);

outTwo=new ObjectOutputStream(outOne);

學(xué)生散列表.put(number, 學(xué)生);

outTwo.writeObject(學(xué)生散列表);

outTwo.close();

outOne.close();

學(xué)號(hào).setText(null);

姓名.setText(null);

專業(yè).setText(null);

年級(jí).setText(null);

出生.setText(null);

}

catch(Exception ee){

System.out.println("錄入修改出現(xiàn)異常!");

修改.setEnabled(false);

}

}

}

class DeleteAct implements ActionListener{

public void actionPerformed(ActionEvent e){

修改.setEnabled(false);

String number=學(xué)號(hào).getText();

if(number.length()0){

try{

inOne=new FileInputStream(file);

inTwo=new ObjectInputStream(inOne);

學(xué)生散列表=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee){}

if(學(xué)生散列表.containsKey(number)){

Student stu=(Student)學(xué)生散列表.get(number);

姓名.setText(stu.getName());

專業(yè).setText(stu.getSpecialty());

年級(jí).setText(stu.getGrade());

出生.setText(stu.getBorth());

if(stu.getSex().equals("男"))

else

}

String m="確定要?jiǎng)h除該學(xué)生的記錄嗎?";

int ok=JOptionPane.showConfirmDialog(null,m,"確認(rèn)",

JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);

if(ok==JOptionPane.YES_OPTION){

學(xué)生散列表.remove(number);

try{

outOne=new FileOutputStream(file);

outTwo=new ObjectOutputStream(outOne);

outTwo.writeObject(學(xué)生散列表);

outTwo.close();

outOne.close();

學(xué)號(hào).setText(null);

姓名.setText(null);

專業(yè).setText(null);

年級(jí).setText(null);

出生.setText(null);

}

catch(Exception ee)

}

else if(ok==JOptionPane.NO_OPTION){

學(xué)號(hào).setText(null);

姓名.setText(null);

專業(yè).setText(null);

年級(jí).setText(null);

出生.setText(null);

}

else{

String warning="該學(xué)號(hào)不存在!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}

}

else{

String warning="必須輸入學(xué)號(hào)!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}

}

}

class ShowAct implements ActionListener{

public void actionPerformed(ActionEvent e){

new StudentShow(file);

}

}

class StudentShow extends JDialog{

Hashtable 學(xué)生散列表= null;

JTextArea 顯示=null;

FileInputStream inOne=null;

ObjectInputStream inTwo=null;

File file=null;

public StudentShow(File file){

super(new JFrame(),"顯示對(duì)話框");

this.file=file;

顯示=new JTextArea(16,30);

try{

inOne=new FileInputStream(file);

inTwo=new ObjectInputStream(inOne);

學(xué)生散列表=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee){}

if(學(xué)生散列表.isEmpty())顯示.append("目前還沒有學(xué)生的信息記錄!\n");

else{

顯示.setText("學(xué)號(hào) 姓名 性別 專業(yè) 年級(jí) 出生\n");

for(Enumeration enm=學(xué)生散列表.elements();enm.hasMoreElements();){

Student stu=(Student)enm.nextElement();

String sex="";

if(stu.getSex().equals("男"))sex="男";

else sex="女";

String str=stu.getNumber()+","+stu.getName()+","+sex+","

+stu.getSpecialty()+","+stu.getGrade()+","+stu.getBorth()+"\n";

顯示.append(str);

}

}

JScrollPane scroll=new JScrollPane(顯示);

Container con=getContentPane();

con.add("Center",scroll);

con.validate();

setVisible(true);

setBounds(200,200,400,300);

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e)

}

);

}

}

}

利用swing設(shè)計(jì)一個(gè)班級(jí)學(xué)生信息管理系統(tǒng),一道JAVA題 求代碼,不要廢話

public?class?RandomUtils?{

public?static?String?randomId(){

Random?random?=?new?Random();

StringBuilder?sb?=?new?StringBuilder();

for?(int?i?=?0;?i??6;?i++)?{

sb.append(random.nextInt(10));

}

return?sb.toString();

}

public?static?int?randomIntId(){

Random?random?=?new?Random();

StringBuilder?sb?=?new?StringBuilder();

for?(int?i?=?0;?i??6;?i++)?{

sb.append(random.nextInt(10));

}

return?Integer.parseInt(sb.toString());

}

public?static?String?randomName(){

String[]?name1?=?{"趙","錢","孫","李","周","吳","鄭","王","張","劉"};

String[]?name2?=?{"一","二","三","四","五","六","七","八","九","十"};

Random?random?=?new?Random();

StringBuilder?sb?=?new?StringBuilder();

sb.append(name1[random.nextInt(10)]);

sb.append(name2[random.nextInt(10)]);

sb.append(name2[random.nextInt(10)]);

return?sb.toString();

}

public?static?String?randomSex(){

Random?random?=?new?Random();

return?random.nextInt(4)/2==0?"男":"女";

}

public?static?int?randomAge(int?min,?int?max){

Random?random?=?new?Random();

return?random.nextInt(min)?+?max-min;

}

public?static?int?randomScore(){

Random?random?=?new?Random();

return?(int)(random.nextDouble()*100%100);

}

public?static?String?randomAddress(){

String[]?address1?=?{"商業(yè)","紅葉","安康","河南","長海","黃河","桐柏","科學(xué)","瑞達(dá)","花園"};

String[]?address2?=?{"東","南","西","北","中"};

String[]?address3?=?{"街","路","大道","巷"};

Random?random?=?new?Random();

StringBuilder?sb?=?new?StringBuilder();

sb.append(address1[random.nextInt(10)]);

sb.append(address2[random.nextInt(5)]);

sb.append(address3[random.nextInt(4)]);

sb.append(random.nextInt(1000)+1);

sb.append("號(hào)");

return?sb.toString();

}

}

import?javax.swing.*;

import?javax.swing.event.TreeSelectionEvent;

import?javax.swing.event.TreeSelectionListener;

import?javax.swing.table.DefaultTableModel;

import?javax.swing.tree.DefaultMutableTreeNode;

import?java.awt.*;

import?java.util.*;

import?java.util.List;

public?class?StudentManage?extends?JFrame{

public?final?static?String[]?CH_NUM?=?{"一","二","三","四","五","六","七","八","九","十"};

public?final?static?String?ROOT?=?"班級(jí)管理";

public?final?static?int?GRADE_NUM?=?3;

public?final?static?int?CLASS_NUM?=?3;

private?MapString,?ListStudent?classes;

public?StudentManage()?{

setTitle("學(xué)生管理系統(tǒng)");

setSize(300,?300);

setLayout(new?BorderLayout());

if(classes?==?null)?classes?=?new?HashMap();

DefaultMutableTreeNode?top?=?new?DefaultMutableTreeNode(ROOT);

DefaultMutableTreeNode[]?gradeNodes?=?new?DefaultMutableTreeNode[GRADE_NUM];

for?(int?i?=?0;?i??GRADE_NUM;?i++)?{

gradeNodes[i]?=?new?DefaultMutableTreeNode(CH_NUM[i]?+?"年級(jí)");

for?(int?j?=?0;?j??CLASS_NUM;?j++)?{

gradeNodes[i].add(new?DefaultMutableTreeNode(CH_NUM[j]?+?"班"));

}

top.add(gradeNodes[i]);

}

final?JTree?tree?=?new?JTree(top);

String?title[]?=?{"ID","姓名","性別","年齡","地址"};

final?DefaultTableModel?model?=?new?DefaultTableModel(title,?0);

JTable?table=new?JTable(model);

tree.addTreeSelectionListener(new?TreeSelectionListener()?{

@Override

public?void?valueChanged(TreeSelectionEvent?e)?{

DefaultMutableTreeNode?node?=?(DefaultMutableTreeNode)?tree?.getLastSelectedPathComponent();

if?(node?==?null)?return;

Object?object?=?node.getUserObject();

if?(node.isLeaf())?{

ListStudent?stdList?=?classes.get(getFullPath(node));

Object[][]?data?=?new?Object[stdList.size()][5];

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

data[i][0]?=?stdList.get(i).getId();

data[i][1]?=?stdList.get(i).getName();

data[i][2]?=?stdList.get(i).getSex();

data[i][3]?=?stdList.get(i).getAge();

data[i][4]?=?stdList.get(i).getAddress();

}

while(model.getRowCount()0){

model.removeRow(model.getRowCount()-1);

}

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

model.addRow(data[i]);

}

model.fireTableDataChanged();

}

}

});

add(tree,?BorderLayout.WEST);

add(new?JScrollPane(table),?BorderLayout.CENTER);

setVisible(true);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

private?String?getFullPath(DefaultMutableTreeNode?defaultMutableTreeNode){

StringBuilder?sb?=?new?StringBuilder();

Object[]?objs?=?defaultMutableTreeNode.getUserObjectPath();

for?(int?i?=?0;?i??objs.length;?i++)?{

sb.append(objs[i]);

}

return?sb.toString().replace(ROOT,"");

}

public?void?init(){

for?(int?i?=?0;?i??GRADE_NUM;?i++)?{

for?(int?j?=?0;?j??CLASS_NUM;?j++)?{

int?n?=?new?Random().nextInt(30)+1;

ListStudent?stdList?=?new?ArrayList(n);

for?(int?k?=?0;?k??n;?k++)?{

stdList.add(new?Student(RandomUtils.randomIntId(),RandomUtils.randomName(),RandomUtils.randomSex(),

RandomUtils.randomAge(6,12),RandomUtils.randomAddress()));

}

classes.put(CH_NUM[i]?+?"年級(jí)"+?CH_NUM[j]?+"班",?stdList);

}

}

}

public?static?void?main(String[]?args)?{

StudentManage?studentManage?=?new?StudentManage();

studentManage.init();

}

}

class?Student?{

private?int?id;

private?String?name;

private?String?sex;

private?int?age;

private?String?address;

public?Student(int?id,?String?name,?String?sex,?int?age,?String?address)?{

this.id?=?id;

this.name?=?name;

this.sex?=?sex;

this.age?=?age;

this.address?=?address;

}

public?Student()?{

}

public?int?getId()?{

return?id;

}

public?String?getName()?{

return?name;

}

public?String?getSex()?{

return?sex;

}

public?int?getAge()?{

return?age;

}

public?String?getAddress()?{

return?address;

}

@Override

public?String?toString()?{

return?"Student{"?+

"id="?+?id?+

",?name='"?+?name?+?'\''?+

",?sex='"?+?sex?+?'\''?+

",?age="?+?age?+

",?address='"?+?address?+?'\''?+

'}';

}

}

急求java學(xué)生信息管理系統(tǒng)源代碼,帶有連接數(shù)據(jù)庫的,萬分感謝

import java.awt.BorderLayout;

import java.awt.CardLayout;

import java.awt.Container;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.Icon;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JPanel;

import javax.swing.JToolBar;

import javax.swing.SwingConstants;

public class MainFrame extends JFrame implements ActionListener{

InsertPanel ip = null;

SelectPanel sp = null;

JPanel pframe;

JButton jb1,jb2,jb3;

JMenuItem jm11,jm21,jm22,jm23,jm31,jm32,jm41,jm42;

CardLayout clayout;

public MainFrame(String s){

super(s);

JMenuBar mb = new JMenuBar();

this.setJMenuBar(mb);

JMenu m1 = new JMenu("系統(tǒng)");

JMenu m2 = new JMenu("基本信息");

JMenu m3 = new JMenu("成績");

JMenu m4 = new JMenu("獎(jiǎng)懲");

mb.add(m1);

mb.add(m2);

mb.add(m3);

mb.add(m4);

jm11 = new JMenuItem("退出系統(tǒng)");

jm21 = new JMenuItem("輸入");

jm22 = new JMenuItem("查詢");

jm23 = new JMenuItem("更改");

jm31 = new JMenuItem("輸入成績");

jm32 = new JMenuItem("查詢成績");

jm41 = new JMenuItem("獎(jiǎng)勵(lì)");

jm42 = new JMenuItem("處分");

m1.add(jm11);

m2.add(jm21);

m2.add(jm22);

m2.add(jm23);

m3.add(jm31);

m3.add(jm32);

m4.add(jm41);

m4.add(jm42);

Icon i1 = new ImageIcon();

Icon i2 = new ImageIcon();

Icon i3 = new ImageIcon();

jb1 = new JButton(i1);

jb1.setToolTipText("輸入");

jb2 = new JButton(i2);

jb2.setToolTipText("查詢");

jb3 = new JButton(i3);

jb3.setToolTipText("退出");

JToolBar tb = new JToolBar("系統(tǒng)工具");

tb.add(jb1);

tb.add(jb2);

tb.add(jb3);

add(tb,BorderLayout.NORTH);

jm11.addActionListener(this);

jm21.addActionListener(this);

jm22.addActionListener(this);

jb1.addActionListener(this);

jb2.addActionListener(this);

jb3.addActionListener(this);

clayout = new CardLayout();

pframe = new JPanel(clayout);

add(pframe);

JPanel mainp = new JPanel(new BorderLayout());

JLabel mainl = new JLabel("學(xué)生信息管理平臺(tái)",SwingConstants.CENTER);

mainl.setFont(new Font("serif",Font.BOLD,30));

mainp.add(mainl);

pframe.add(mainp,"main");

clayout.show(pframe, "main");

}

public void actionPerformed(ActionEvent e){

if(e.getSource() == jm21 || e.getSource() == jb1){

if(ip == null){

ip= new InsertPanel();

pframe.add(ip,"insert");

}

clayout.show(pframe, "insert");

this.setTitle("輸入學(xué)生信息");

}

else if(e.getSource() == jm22 || e.getSource() == jb2){

if(sp == null){

sp= new SelectPanel();

pframe.add(sp,"select");

}

clayout.show(pframe, "select");

this.setTitle("查詢學(xué)生信息");

}

else if(e.getSource() == jm11 || e.getSource() == jb3){

System.exit(0);

}

}

}

第二個(gè):

import javax.swing.JFrame;

public class MainTest {

public static void main(String [] args){

MainFrame f = new MainFrame("學(xué)生信息管理平臺(tái)");

f.setSize(400,300);

f.setLocation(350,250);

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.setVisible(true);

}

}

第二個(gè):

import java.sql.Connection;

import java.sql.DriverManager;

public class MySQLConnection {

static Connection getCon(){

Connection con = null;

try{

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

con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","123");

}

catch(Exception e){

System.out.println("建立數(shù)據(jù)庫連接遇到異常!");

}

return con;

}

}

第四個(gè):

import java.awt.BorderLayout;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JTextField;

import javax.swing.SwingConstants;

public class SelectPanel extends JPanel implements ActionListener{

JButton jb;

JTextField jt;

JTextField jt1,jt2,jt3,jt4;

public SelectPanel(){

JLabel jl = new JLabel("請(qǐng)輸入學(xué)號(hào):",SwingConstants.CENTER);

jt = new JTextField();

jb = new JButton("確定");

JPanel jp1 = new JPanel(new GridLayout(1,3));

jp1.add(jl);

jp1.add(jt);

jp1.add(jb);

JLabel j1,j2,j3,j4;

j1 = new JLabel("學(xué)號(hào):",SwingConstants.CENTER);

j2 = new JLabel("姓名:",SwingConstants.CENTER);

j3 = new JLabel("性別:",SwingConstants.CENTER);

j4 = new JLabel("年齡:",SwingConstants.CENTER);

jt1 = new JTextField(6);

jt1.setEditable(false);

jt2 = new JTextField(6);

jt2.setEditable(false);

jt3 = new JTextField(6);

jt3.setEditable(false);

jt4 = new JTextField(6);

jt4.setEditable(false);

JPanel jp2 = new JPanel(new BorderLayout());

JPanel jp3 = new JPanel(new GridLayout(4,2));

jp2.add(new JLabel(""),BorderLayout.NORTH);

jp3.add(j1);

jp3.add(jt1);

jp3.add(j2);

jp3.add(jt2);

jp3.add(j3);

jp3.add(jt3);

jp3.add(j4);

jp3.add(jt4);

jp2.add(jp3);

this.setLayout(new BorderLayout());

add(jp1,BorderLayout.NORTH);

add(jp2);

jb.addActionListener(this);

}

public void actionPerformed(ActionEvent e){

if(e.getSource() == jb){

String stuNo = jt.getText().trim();

Student s = new Student();

boolean b = true;

try{

b = s.selectByStuNo(stuNo);

}

catch(Exception ex){

System.out.println("查詢學(xué)生信息遇到異常!");

}

if(b){

jt1.setText(s.getStuNo());

jt2.setText(s.getName());

jt3.setText(s.getGender());

int a = s.getAge();

Integer i = new Integer(a);

jt4.setText(i.toString());

}

else{

JOptionPane.showMessageDialog(null, "無此學(xué)生!");

}

}

}

}

第五個(gè):

import javax.swing.JFrame;

public class SelectTest {

public static void main(String [] args){

JFrame f = new JFrame("查詢學(xué)生信息");

SelectPanel p = new SelectPanel();

f.add(p);

f.setSize(400,300);

f.setLocation(300,250);

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.setVisible(true);

}

}

第六個(gè):

import java.sql.Connection;

import java.sql.ResultSet;

import java.sql.Statement;

public class Student {

String stuNo;

String name;

String gender;

int age;

public Student(){}

public Student(String stuNo,String name,String gender, int age){

this.stuNo = stuNo;

this.name = name;

this.gender = gender;

this.age = age;

}

public String getStuNo(){

return stuNo;

}

public void setStuNo(String stuNo){

this.stuNo = stuNo;

}

public String getName(){

return name;

}

public void setName(String name){

this.name = name;

}

public String getGender(){

return gender;

}

public void setGender(String gender){

this.gender = gender;

}

public int getAge(){

return age;

}

public void setAge(int age){

this.age = age;

}

public boolean insertStudent(){

boolean b = true;

try{

Connection con = MySQLConnection.getCon();

Statement statement = con.createStatement();

String sql = "insert into student values('" + stuNo + "','" + name +"','" + gender + "'," + age + ")";

sql = new String(sql.getBytes("gb2312"),"ISO8859_1");

statement.executeUpdate(sql);

con.close();

}

catch(Exception e){

b = false;

System.out.println("插入數(shù)據(jù)庫遇到異常!");

}

return b;

}

public boolean selectByStuNo(String stuNo)throws Exception{

boolean b = true;

Connection con = MySQLConnection.getCon();

Statement statement = con.createStatement();

String sql = "select * from student where stuNo =" + stuNo;

ResultSet rs = statement.executeQuery(sql);

if(rs != null rs.next()){

String no = rs.getString(1);

this.setStuNo(no);

String n = rs.getString(2);

n = new String(n.getBytes("ISO8859_1"),"gb2312");

this.setName(n);

String g = rs.getString(3);

g = new String (g.getBytes("ISO8859_1"),"gb2312");

this.setGender(g);

this.setAge(rs.getInt(4));

b = true;

}

rs.close();

statement.close();

con.close();

return b;

}

}

數(shù)據(jù)庫你自己弄吧,我沒時(shí)間弄了!初學(xué)得多動(dòng)手哦

分享題目:關(guān)于java信息添加系統(tǒng)代碼的信息
轉(zhuǎn)載注明:http://m.rwnh.cn/article0/hiejio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、網(wǎng)站排名、手機(jī)網(wǎng)站建設(shè)網(wǎng)站設(shè)計(jì)、外貿(mào)建站、動(dòng)態(tài)網(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)

成都做網(wǎng)站
科技| 蓝田县| 时尚| 石渠县| 射洪县| 东乌珠穆沁旗| 无极县| 昭平县| 闵行区| 故城县| 望奎县| 大兴区| 铜陵市| 旬邑县| 新闻| 晋城| 平塘县| 临夏市| 蚌埠市| 于都县| 盐津县| 北川| 儋州市| 福建省| 长宁县| 广南县| 扎鲁特旗| 琼结县| 南和县| 睢宁县| 和政县| 屯门区| 慈溪市| 澄城县| 南木林县| 阿荣旗| 清丰县| 枞阳县| 黄山市| 闸北区| 延庆县|