資源簡介
一款小型的桌面應用程序 java GUI+SQL2000
用到了視圖和存儲過程 源碼簡單 適合j2se初學者

代碼片段和文件信息
package?Student;
import?javax.swing.*;
import?java.awt.*;
import?java.awt.event.*;
import?java.sql.*;
import?java.util.Vector;
public?class?Login?extends?Jframe{
JButton?jb1=new?JButton();
JButton?jb2=new?JButton();
JButton?jb3=new?JButton();
JTextField?tx1=new?JTextField(12);
JPasswordField?pw=new?JPasswordField(12);
JPanel?jp1=new?JPanel();
JLabel?jl=new?JLabel();
JLabel?jl1=new?JLabel();
JLabel?jl2=new?JLabel();
Container?cp;
Container?thiswindow=this;
???private?Login()
{
cp=this.getContentPane();
cp.setLayout(new?BorderLayout());
jb3.setText(“退出“);
jb3.setFont(new?Font(“SansSerif“?Font.PLAIN?12));
jb3.setForeground(Color.BLUE);
jb3.addActionListener(new?ActionListener()?{
public?void?actionPerformed(ActionEvent?e)
{
System.exit(0);
}
});
jb1.setForeground(Color.BLUE);
jb1.setText(“清除“);
jb1.setFont(new?Font(“SansSerif“?Font.PLAIN?12));
jb1.setForeground(Color.BLUE);
jb2.setText(“登入“);
jb2.setFont(new?Font(“SansSerif“?Font.PLAIN?12));
jb2.setForeground(Color.BLUE);
jb2.addActionListener(new?ActionListener()
{
public?void?actionPerformed?(ActionEvent?e)
{
String?password=pw.getText();
String?userid=tx1.getText();
ResultSet?rs;
String?key=null;
try{
MyJDBC?getkey=new?MyJDBC();
rs=getkey.exceteQuery(“SELECT?sidkeys?FROM?student?where?sid=‘“+userid+“‘“);
???????????????????
while?(rs.next())?{
key=rs.getString(2).trim();
System.out.println(“key:“+key);
}
if(key.equals(password))
{
StudentUI?x=new?StudentUI(useridpassword);
thiswindow.setVisible(false);
}
else?
{
JOptionPane.showMessageDialog(null“You?ID?Or?Password?is?wrong“);
}
rs.close();
}catch(Exception?f){f.printStackTrace();
JOptionPane.showMessageDialog(null“不能連接數據庫“);}
}
}
);
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jb1.addActionListener(new?ActionListener(){
public?void?actionPerformed(ActionEvent?e)
{
pw.setText(““);
tx1.setText(““);
}
});
jl.setText(“歡迎使用選課系統“);
jl.setFont(new?Font(“SansSerif“?Font.BOLD?24));
jl.setForeground(Color.RED);
jl1.setText(“用戶ID“);
jl1.setForeground(Color.GREEN);
jl2.setText(“密碼??“);
jl2.setForeground(Color.GREEN);
JPanel?jpt1=new?JPanel();
JPanel?jpt2=new?JPanel();
JPanel?jp2=new?JPanel();
jpt1.add(jl1);
jpt1.add(tx1);
jpt2.add(jl2);
jpt2.add(pw);
jp2.add(jpt1);
jp2.add(jpt2);
cp.add(jlBorderLayout.NORTH);
cp.add(jp1BorderLayout.SOUTH);
cp.add(jp2BorderLayout.CENTER);
this.setSize(300250);
this.settitle(“CRS-sutdent“);
this.setLocation(350250);
this.setVisible(true);
}
public?static?void?main(String[]?args)?{
try?{
Login?login?=?new?Login();
}?catch?(Exception?e)?{
e.printStackTrace();
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????934400??2009-05-12?19:35??學生選課系統\學生選課系統\Databa
?????文件??????13202??2009-05-12?19:38??學生選課系統\學生選課系統\Databa
?????文件?????166400??2006-06-05?23:23??學生選課系統\學生選課系統\Databa
?????文件????????226??2009-05-12?19:18??學生選課系統\學生選課系統\DB2Design\.classpath
?????文件????????226??2006-05-22?19:06??學生選課系統\學生選課系統\DB2Design\.classpath.bak
?????文件????????385??2006-05-22?19:06??學生選課系統\學生選課系統\DB2Design\.project
?????文件????????658??2009-05-12?19:20??學生選課系統\學生選課系統\DB2Design\Student\Login$1.class
?????文件???????2271??2009-05-12?19:20??學生選課系統\學生選課系統\DB2Design\Student\Login$2.class
?????文件????????840??2009-05-12?19:20??學生選課系統\學生選課系統\DB2Design\Student\Login$3.class
?????文件???????2972??2009-05-12?19:20??學生選課系統\學生選課系統\DB2Design\Student\Login.class
?????文件???????2948??2009-05-12?19:20??學生選課系統\學生選課系統\DB2Design\Student\Login.java
?????文件???????2094??2009-05-12?19:18??學生選課系統\學生選課系統\DB2Design\Student\MyJDBC.class
?????文件???????1445??2009-05-12?18:14??學生選課系統\學生選課系統\DB2Design\Student\MyJDBC.java
?????文件????????697??2009-05-12?19:18??學生選課系統\學生選課系統\DB2Design\Student\StudentSelect$1.class
?????文件???????1735??2009-05-12?19:18??學生選課系統\學生選課系統\DB2Design\Student\StudentSelect$1Confirm.class
?????文件???????2614??2009-05-12?19:18??學生選課系統\學生選課系統\DB2Design\Student\StudentSelect.class
?????文件???????2008??2009-05-12?19:08??學生選課系統\學生選課系統\DB2Design\Student\StudentSelect.java
?????文件???????2267??2009-05-12?19:29??學生選課系統\學生選課系統\DB2Design\Student\StudentUI$1.class
?????文件???????2619??2009-05-12?19:29??學生選課系統\學生選課系統\DB2Design\Student\StudentUI$1InsaltResult.class
?????文件???????2554??2009-05-12?19:29??學生選課系統\學生選課系統\DB2Design\Student\StudentUI$1Personal.class
?????文件???????1037??2009-05-12?19:29??學生選課系統\學生選課系統\DB2Design\Student\StudentUI$1SelectCourse.class
?????文件????????910??2009-05-12?19:29??學生選課系統\學生選課系統\DB2Design\Student\StudentUI$1UpdataSData.class
?????文件????????769??2009-05-12?19:29??學生選課系統\學生選課系統\DB2Design\Student\StudentUI$2.class
?????文件???????3562??2009-05-12?19:29??學生選課系統\學生選課系統\DB2Design\Student\StudentUI.class
?????文件???????6072??2009-05-12?19:29??學生選課系統\學生選課系統\DB2Design\Student\StudentUI.java
?????文件????????655??2009-05-12?19:31??學生選課系統\學生選課系統\DB2Design\Student\Updata$1.class
?????文件???????1798??2009-05-12?19:31??學生選課系統\學生選課系統\DB2Design\Student\Updata$1UpdataCommit.class
?????文件???????3255??2009-05-12?19:31??學生選課系統\學生選課系統\DB2Design\Student\Updata.class
?????文件???????2741??2009-05-12?19:31??學生選課系統\學生選課系統\DB2Design\Student\Updata.java
?????文件????????226??2009-05-12?18:54??學生選課系統\學生選課系統\Professor\.classpath
............此處省略42個文件信息
評論
共有 條評論