Java课程设计 学生基本信息管理个人博客
学生基本信息管理系统个人博客
团队课程设计链接
http://www.cnblogs.com/ll321/p/7067598.html
个人负责模块
负责部分界面设计,处理代码;
处理部分数据库数据。
自己的代码提交记录截图
自己负责模块或任务详细说明
数据库数据删除(在删除界面把数据库数据删除)
package database;
import java.sql.SQLException;
public class DELETE {
public static String[][] delete(String name){
String str ="delete from students where name="+"'"+name+"'"+";";
String[][] strs = new String[100][8];
try{
DBUtil.exec(str);
}catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return strs;
}
}
图形界面设计和处理
1.搜索界面设计(把数据库的数据输送到图形界面)
public SearchJFrame() {
initComponents();
}
private void Button1ActionPerformed(java.awt.event.ActionEvent evt) {
String name = TextField1.getText().trim();
if(name.length()==0){
JOptionPane.showMessageDialog(null,"输入不能为空!");
}
else{
String[][] strs = SEARCH.serach(name);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 8; j++) {
System.out.print(strs[i][j] + " ");
}
System.out.println();
}
ImformationJFrame ImformationJFrame = new ImformationJFrame(strs);
ImformationJFrame.setVisible(true);
this.setVisible(false);
}
}
private void Button2ActionPerformed(java.awt.event.ActionEvent evt) {
MainJFrame MainJFrame = new MainJFrame();
MainJFrame.setVisible(true);
this.setVisible(false);
}
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(SearchJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SearchJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SearchJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SearchJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
}
2.添加界面设计(把输入的数据输送到数据库)
public class AddJFrame extends javax.swing.JFrame {
public AddJFrame() {
initComponents();
}
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
AddButton.setText("添加");
AddButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
try {
AddButtonActionPerformed(evt);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
Button2.setText("返回");
Button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button2ActionPerformed(evt);
}
});
pack();
}
private void AddButtonActionPerformed(java.awt.event.ActionEvent evt) throws SQLException {
String number = TextField1.getText().trim();
String name = TextField2.getText().trim();
String gender = TextField3.getText().trim();
String birthdate = TextField4.getText().trim();
String politics = TextField5.getText().trim();
String address = TextField6.getText().trim();
String telephone = TextField7.getText().trim();
String dormitory = TextField8.getText().trim();
if(number.length()==0||name.length()==0||gender.length()==0||birthdate.length()==0||politics.length()==0||address.length()==0||telephone.length()==0||dormitory.length()==0){
JOptionPane.showMessageDialog(null, "有数据为空!!");
}
else{
ADD.add(number, name, gender, birthdate, politics, address, telephone, dormitory);
JOptionPane.showMessageDialog(null, "添加成功!");
}
}
private void Button2ActionPerformed(java.awt.event.ActionEvent evt) {
MainJFrame MainJFrame = new MainJFrame();
MainJFrame.setVisible(true);
this.setVisible(false);
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(AddJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AddJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AddJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AddJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new AddJFrame().setVisible(true);
}
});
}
}
3.删除界面设计(将数据库的数据删除)
private void Button2ActionPerformed(java.awt.event.ActionEvent evt) {
MainJFrame MainJFrame = new MainJFrame();
MainJFrame.setVisible(true);
this.setVisible(false);
}
private void Button1ActionPerformed(java.awt.event.ActionEvent evt) {
String number = TextField1.getText().trim();
String name = TextField2.getText().trim();
if(name.length()==0&&number.length()==0){
JOptionPane.showMessageDialog(null,"输入不能为空!" );
}
else{
database.DELETE.delete(name);
}
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(DeleteJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DeleteJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DeleteJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DeleteJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new DeleteJFrame().setVisible(true);
}
});
}
4.修改界面设计(修改数据库的数据内容)
private void Button1ActionPerformed(java.awt.event.ActionEvent evt) {
String number = TextField1.getText().trim();
String name = TextField2.getText().trim();
String gender = TextField3.getText().trim();
String birthdate = TextField4.getText().trim();
String politics = TextField5.getText().trim();
String address = TextField6.getText().trim();
String telephone = TextField7.getText().trim();
String dormitory = TextField8.getText().trim();
CHANGE.change(number,name,gender, birthdate, politics, address, telephone, dormitory);
}
private void Button2ActionPerformed(java.awt.event.ActionEvent evt) {
MainJFrame MainJFrame = new MainJFrame();
MainJFrame.setVisible(true);
this.setVisible(false);
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ChangeJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ChangeJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ChangeJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ChangeJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ChangeJFrame().setVisible(true);
}
});
}
课程设计感想
通过这次的课程设计,我认识到了自己的不足之处,对于一部分知识掌握的还不是很好,还有很多的欠缺之处,需要自己不断的改进。而且在这次课设的过程中,大大地提升了对net beans 和数据库的使用熟练度,有了很大收获。