java編寫網(wǎng)絡(luò)賬號管理系統(tǒng)源碼
《java編寫網(wǎng)絡(luò)賬號管理系統(tǒng)源碼》由會員分享,可在線閱讀,更多相關(guān)《java編寫網(wǎng)絡(luò)賬號管理系統(tǒng)源碼(74頁珍藏版)》請在裝配圖網(wǎng)上搜索。
1、 網(wǎng)絡(luò)賬號管理系統(tǒng) 數(shù)據(jù)庫名稱:T_user,T_source T_user: T_source: 界面設(shè)計 用戶登錄界面: 登錄后顯示界面: 修改密碼界面: 按網(wǎng)站查詢界面: 按賬號查詢界面: 修改界面:
2、 添加賬號界面: 賬號添加成功: 刪除界面: 源碼: package com.GUI.zzx; import java.awt.Toolkit; import java.awt.Dimension; import javax.swing.*; //窗體居中類 public class WindowsCenter { public WindowsCenter() { }
3、 @SuppressWarnings("deprecation") public static void Center(JFrame frame){ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.he
4、ight; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.show(); } } pac
5、kage com.GUI.zzx; import h2.alterpass; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Image; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.BorderLayout; import javax.swing.BoxLayout; import javax.swing.JButton; import jav
6、a.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.CardLayout; import javax.swing.JSplitPane; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing
7、.JTable; import javax.swing.JTextField; import javax.swing.JPasswordField; import javax.swing.SwingConstants; import javax.swing.JScrollPane; import User.*; import h2.AddResource; @SuppressWarnings("serial") public class Window extends JFrame { private JPanel panelMain ,panelFirst ,panelAd
8、d; private JButton btnMain,btnNet,btnAccount,btnAdd,btnExit; private CardLayout card ,card1 ,card2; private JLabel lbChange; private JTable table1; private JTable table2; private JTextField textField; private static String usertemp=""; /** * Create the application. */ public
9、Window() { initWin(); initListener(); } /** * InitiWin the contents of the frame. */ ///============================我是華麗的分割線(>^ω^<)喵=====窗口實現(xiàn)==========================================// public void initWin() { this.setTitle("網(wǎng)絡(luò)賬號管理系統(tǒng)"); this.setBounds(100, 100, 600, 400);
10、 this.setResizable(false); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()) { @Override protected void paintComponent(Graphics g) { ImageIcon icon = new ImageIcon(this.getClass().getResource("res/test.jpg")); Im
11、age img = icon.getImage(); g.drawImage(img, 0, 0, icon.getIconWidth(), icon.getIconHeight(), icon.getImageObserver()); } }; getContentPane().add(panel); //=================我是華麗的分割線(>^ω^<)喵============標(biāo)簽欄======================================= JPanel panelBar
12、 = new JPanel(){ @Override protected void paintComponent(Graphics g) { ImageIcon icon = new ImageIcon(this.getClass().getResource("res/test.jpg")); Image img = icon.getImage(); g.drawImage(img, 0, 0, icon.getIconWidth(), icon.getIconHeight(), icon.getImageObserver());
13、 } }; panel.add(panelBar, BorderLayout.NORTH); panelBar.setLayout(new BoxLayout(panelBar, BoxLayout.X_AXIS)); //Icon btnMain_icon =new ImageIcon("\btn_main.png") ; btnMain = new JButton("首頁"); btnMain.setContentAreaFilled(false); btnMain.setForeground(Color.white)
14、; //btnMain.setBorder(BorderFactory.createLineBorder(Color.blue,1)); btnMain.setFont(new Font("楷體", Font.BOLD | Font.ITALIC, 14)); //btnMain.setSize(60,27); panelBar.add(btnMain); btnNet = new JButton("按網(wǎng)站查詢"); btnNet.setContentAreaFilled(false); btnNet.setForeground(C
15、olor.white); btnNet.setEnabled(false); panelBar.add(btnNet); btnNet.setFont(new Font("楷體", Font.BOLD | Font.ITALIC, 14)); btnAccount = new JButton("按賬號查詢"); btnAccount.setContentAreaFilled(false); btnAccount.setForeground(Color.white); btnAccount.setEnabled(false); bt
16、nAccount.setFont(new Font("楷體", Font.BOLD | Font.ITALIC, 14)); panelBar.add(btnAccount); btnAdd = new JButton("添加賬號"); btnAdd.setContentAreaFilled(false); btnAdd.setEnabled(false); btnAdd.setForeground(Color.white); btnAdd.setFont(new Font("楷體", Font.BOLD | Font.ITALIC, 14));
17、 panelBar.add(btnAdd); JLabel lbSpace = new JLabel(" "); panelBar.add(lbSpace); btnExit = new JButton("注銷"); btnExit.setContentAreaFilled(false); btnExit.setEnabled(false); btnExit.setForeground(Color.white); btnExit.s
18、etFont(new Font("楷體", Font.BOLD | Font.ITALIC, 14)); panelBar.add(btnExit); //=========================我是華麗的分割線(>^ω^<)喵====主面板=====================================// panelMain = new JPanel(); panel.add(panelMain, BorderLayout.CENTER); card = new CardLayout(); panelMain.setLayou
19、t(card); //=========================我是華麗的分割線(>^ω^<)喵====首頁=====================================// panelFirst = new JPanel(); card1 = new CardLayout(); panelFirst.setLayout(card1); final JPanel Login = new JPanel() { @Override protected void paintComponent(Graphi
20、cs g) { ImageIcon icon = new ImageIcon(this.getClass().getResource("res/test.jpg")); Image img = icon.getImage(); g.drawImage(img, 0, 0, icon.getIconWidth(), icon.getIconHeight(), icon.getImageObserver()); } }; final JPanel Register = new JPanel() {
21、 @Override protected void paintComponent(Graphics g) { ImageIcon icon = new ImageIcon(this.getClass().getResource("res/test.jpg")); Image img = icon.getImage(); g.drawImage(img, 0, 0, icon.getIconWidth(), icon.getIconHeight(), icon.getImageObserver()); }
22、 }; final JPanel pl3 = new JPanel(); card2 = new CardLayout(); ///////////////////////////////////////登陸頁//////////////////////////////////////////////////////////////////// Box hbox1 = Box.createHorizontalBox(); Box hbox2 = Box.createHorizontalBox(); Box hbox3 =
23、 Box.createHorizontalBox(); Box hbox4 = Box.createHorizontalBox(); Box vbox1= Box.createVerticalBox(); JLabel lbLogin = new JLabel("用戶登錄"); lbLogin.setFont(new Font("楷體", Font.BOLD, 18)); lbLogin.setForeground(Color.red); JLabel lbUser= new JLabel("用戶名"); lbUser.setFont(new
24、Font("楷體", Font.BOLD, 14)); JLabel lbPwd = new JLabel("密 碼"); lbPwd.setFont(new Font("楷體", Font.BOLD, 14)); final JTextField textUser = new JTextField(20); final JPasswordField textPwd = new JPasswordField(20); JButton btnLogin = new JButton("登錄"); btnLogin.setFont(new Fon
25、t("楷體", Font.BOLD, 14)); btnLogin.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub //獲得輸入的用戶名和密碼 String username = textUser.getText(); char pass[] = textPwd.getPassword(); St
26、ringBuffer sb = new StringBuffer(); for (int i = 0; i < pass.length; i++) { sb.append(pass[i]); } String password = sb.toString(); //判斷登陸 login log = new login(); if(log.log(username, password)){ usertemp = username; card1.show(panelFirst, "3");
27、 textField.setText(usertemp); btnNet.setEnabled(true); btnAccount.setEnabled(true); btnAdd.setEnabled(true); btnExit.setEnabled(true); } } }); JButton btnReg = new JButton("注冊"); btnReg.setFont(new Font("楷體", Font.BOLD, 14)); btnReg.addActionListener
28、(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub card1.show(panelFirst, "2"); } }); hbox1.add(lbLogin); hbox2.add(lbUser); hbox2.add(textUser); hbox3.add(lbPwd); hbox3.add(textPwd)
29、; hbox4.add(btnLogin); hbox4.add(Box.createHorizontalStrut(20)); hbox4.add(btnReg); vbox1.add(Box.createVerticalStrut(30)); vbox1.add(hbox1); vbox1.add(Box.createVerticalStrut(20)); vbox1.add(hbox2); vbox1.add(Box.createVerticalStrut(20)); vbox1.add(hbox3); vbox1.ad
30、d(Box.createVerticalStrut(20)); vbox1.add(hbox4); vbox1.add(Box.createVerticalStrut(30)); Login.add(vbox1); final JPanel pr3= new JPanel(card2); JSplitPane Setting = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,pl3,pr3); pl3.setLayout(null); JLabel label = new JLabel("用戶名"
31、); label.setFont(new Font("楷體", Font.BOLD, 12)); label.setBounds(5, 50, 50, 25); pl3.add(label); textField = new JTextField(usertemp); textField.setEditable(false); textField.setBounds(45, 50, 100, 25); pl3.add(textField); JLabel label_2 = new JLabel("當(dāng)前用戶"); label
32、_2.setFont(new Font("楷體", Font.BOLD, 14)); label_2.setBounds(40, 10, 70, 30); pl3.add(label_2); JButton button_1 = new JButton("修改密碼"); button_1.setFont(new Font("楷體", Font.BOLD, 10)); button_1.setBounds(65, 90, 80, 25); button_1.addActionListener(new ActionListener() {
33、 @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub card2.show(pr3, "1"); } }); pl3.add(button_1); Setting.setDividerLocation(150); Setting.setDividerSize(1); Setting.setResizeWeight(1); /////////////////////////////
34、///////////////////////注冊頁面/////////////////////////////////////////////////////////////////// Box hbox10 = Box.createHorizontalBox(); Box hbox20 = Box.createHorizontalBox(); Box hbox30 = Box.createHorizontalBox(); Box hbox40= Box.createHorizontalBox(); Box hbox50= Box.createHorizonta
35、lBox(); Box vbox20= Box.createVerticalBox(); JLabel lbRegister = new JLabel("用戶注冊"); lbRegister.setFont(new Font("楷體", Font.BOLD, 18)); //lbRegister.setForeground(new Color(180,50,200)); lbRegister.setForeground(Color.red); JLabel lbReUser= new JLabel("用 戶 名"); lbReUser.setF
36、ont(new Font("楷體", Font.BOLD, 14)); JLabel lbRePwd = new JLabel("密 碼"); lbRePwd.setFont(new Font("楷體", Font.BOLD, 14)); JLabel lbRe_Pwd = new JLabel("確認(rèn)密碼"); lbRe_Pwd.setFont(new Font("楷體", Font.BOLD, 14)); final JTextField textReUser = new JTextField(20); final JPasswor
37、dField textRePwd = new JPasswordField(20); final JPasswordField textRe_Pwd = new JPasswordField(20); JButton btnRe = new JButton("確定"); btnRe.setFont(new Font("楷體", Font.BOLD, 14)); btnRe.addActionListener(new ActionListener() { @Override public void actionPerformed(
38、ActionEvent arg0) { // TODO Auto-generated method stub //獲得輸入的信息 String username = textReUser.getText(); char pass[] = textRePwd.getPassword(); char repass[] = textRe_Pwd.getPassword(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < pass.length; i++) {
39、 sb.append(pass[i]); } String password = sb.toString(); StringBuffer sb1 = new StringBuffer(); for (int i = 0; i < repass.length; i++) { sb1.append(repass[i]); } String repassword = sb1.toString(); //處理注冊信息 register re = new register(); if
40、(re.Reg(username, password,repassword)){ Register.setVisible(false); Login.setVisible(true); } } }); JButton btnRe_Set = new JButton("重置"); btnRe_Set.setFont(new Font("楷體", Font.BOLD, 14)); btnRe_Set.addActionListener(new ActionListener() { @Override
41、public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub textReUser.setText(null); textRePwd.setText(null); textRe_Pwd.setText(null); } }); hbox10.add(lbRegister); hbox20.add(lbReUser); hbox20.add(textReUser); hbox30.add(lbRePwd)
42、; hbox30.add(textRePwd); hbox40.add(lbRe_Pwd); hbox40.add(textRe_Pwd); hbox50.add(btnRe); hbox50.add(Box.createHorizontalStrut(20)); hbox50.add(btnRe_Set); vbox20.add(Box.createVerticalStrut(30)); vbox20.add(hbox10); vbox20.add(Box.createVerticalStrut(20)); vbox20.a
43、dd(hbox20); vbox20.add(Box.createVerticalStrut(20)); vbox20.add(hbox30); vbox20.add(Box.createVerticalStrut(20)); vbox20.add(hbox40); vbox20.add(Box.createVerticalStrut(20)); vbox20.add(hbox50); vbox20.add(Box.createVerticalStrut(30)); Register.add(vbox20); //=======
44、==================我是華麗的分割線(>^ω^<)喵=====個人主頁//===================================== JPanel jp0 = new JPanel(){ @Override protected void paintComponent(Graphics g) { ImageIcon icon = new ImageIcon(this.getClass().getResource("res/test.jpg")); Image img = icon.getImage();
45、 g.drawImage(img, 0, 0, icon.getIconWidth(), icon.getIconHeight(), icon.getImageObserver()); } }; /////////////////////////////////////////修改密碼////////////////////////////////////////////////////////////// JPanel jp1 = new JPanel(); Box hbox12 = Box.crea
46、teHorizontalBox(); Box hbox22 = Box.createHorizontalBox(); Box hbox32 = Box.createHorizontalBox(); Box hbox42= Box.createHorizontalBox(); Box hbox52= Box.createHorizontalBox(); Box vbox2= Box.createVerticalBox(); lbChange = new JLabel("修改密碼"); lbChange.setFont(new Font("楷體",
47、 Font.BOLD, 18)); lbChange.setForeground(Color.red); JLabel lbOldPwd= new JLabel("舊 密 碼"); lbOldPwd.setFont(new Font("楷體", Font.BOLD, 14)); JLabel lbNewPwd = new JLabel("新 密 碼"); lbNewPwd.setFont(new Font("楷體", Font.BOLD, 14)); JLabel lbReNewPwd = new JLabel("確認(rèn)密碼"); lbReNewPwd.
48、setFont(new Font("楷體", Font.BOLD, 14)); final JPasswordField textOldPwd = new JPasswordField(20); final JPasswordField textNewPwd = new JPasswordField(20); final JPasswordField textReNewPwd = new JPasswordField(20); JButton btnOk = new JButton("確定"); btnOk.setFont(new
49、Font("楷體", Font.BOLD, 14)); btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) {//修改已有用戶的密碼 //查看兩次密碼是否一致 char[] oldpwd=textOldPwd.getPassword(); StringBuffer sb1=new StringBuffer(); for (int i = 0; i < oldpwd.len
50、gth; i++) { sb1.append(oldpwd[i]); } String oldString=sb1.toString(); char[] newpwd=textNewPwd.getPassword(); StringBuffer sb2=new StringBuffer(); for (int i = 0; i < newpwd.length; i++) { sb2.append(newpwd[i]); } String newString=sb2.toString(); c
51、har[] renewpwd=textReNewPwd.getPassword(); StringBuffer sb3=new StringBuffer(); for (int i = 0; i < renewpwd.length; i++) { sb3.append(renewpwd[i]); } String renewString=sb3.toString(); if(oldString==null||"".equalsIgnoreCase(oldString)){ JOptionPane.showMessageD
52、ialog(null, "請輸入原密碼"); return; } if(newString==null||"".equalsIgnoreCase(newString)){ JOptionPane.showMessageDialog(null, "請輸入新密碼"); return; } if(renewString==null||"".equalsIgnoreCase(renewString)){ JOptionPane.showMessageDialog(null, "請再次輸入新密碼"); r
53、eturn; } if(!renewString.equalsIgnoreCase(newString)){ JOptionPane.showMessageDialog(null, "請確定兩次輸入的密碼要相同"); return; } alterpass alterpass1=new alterpass(); boolean b0=alterpass1.alter(textField.getText(),oldString,newString); alterpass1.getclose(); if(
54、b0){ JOptionPane.showMessageDialog(null, "密碼修改成功!"); } card2.show(pr3, "0"); } }); JButton btnReSet = new JButton("重置"); btnReSet.setFont(new Font("楷體", Font.BOLD, 14)); btnReSet.addActionListener(new ActionListener() { @Override public void actionPerformed(Ac
55、tionEvent arg0) { // TODO Auto-generated method stub textOldPwd.setText(null); textNewPwd.setText(null); textReNewPwd.setText(null); } }); hbox12.add(lbChange); hbox22.add(lbOldPwd); hbox22.add(textOldPwd); hbox32.add(lbNewPwd); hbox32.add(textNewPwd);
56、 hbox42.add(lbReNewPwd); hbox42.add(textReNewPwd); hbox52.add(btnOk); hbox52.add(Box.createHorizontalStrut(20)); hbox52.add(btnReSet); vbox2.add(Box.createVerticalStrut(30)); vbox2.add(hbox12); vbox2.add(Box.createVerticalStrut(20)); vbox2.add(hbox22); vbox2.add(B
57、ox.createVerticalStrut(20)); vbox2.add(hbox32); vbox2.add(Box.createVerticalStrut(20)); vbox2.add(hbox42); vbox2.add(Box.createVerticalStrut(20)); vbox2.add(hbox52); vbox2.add(Box.createVerticalStrut(30)); jp1.add(vbox2); pr3.add("0",jp0); pr3.add("1",jp1); //pr3.add
58、("2",jp2); panelFirst.add("1",Login); panelFirst.add("2",Register); panelFirst.add("3",Setting); //======================我是華麗的分割線(>^ω^<)喵======按網(wǎng)站查詢===============================////////// JPanel pl1 = new JPanel(); JPanel pr1 = new JPanel(); pr1.setLayout(null
59、); pl1.setLayout(new BorderLayout(0, 0)); JPanel pl11 = new JPanel(); pl1.add(pl11, BorderLayout.NORTH); JPanel plMAD = new JPanel(); pl1.add(plMAD, BorderLayout.SOUTH); JButton btModify = new JButton("修改"); btModify.setFont(new Font("楷體", Font.BOLD, 14)); JButton btD
60、elete = new JButton("刪除"); btDelete.setFont(new Font("楷體", Font.BOLD, 14)); plMAD.add(btModify); plMAD.add(btDelete); JSplitPane panelNet = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,pl1,pr1); panelNet.setOpaque(false); pl11.setLayout(new BoxLayout(pl11, BoxLayout.X_AXIS));
61、 JLabel lbNet= new JLabel("網(wǎng)站名"); lbNet.setFont(new Font("楷體", Font.BOLD, 14)); pl11.add(lbNet); final JTextField tfNet = new JTextField(); tfNet.setHorizontalAlignment(SwingConstants.LEFT); //tfNet.setBounds(121, 6, 186, 21); //textField1.setBounds(110, 15, 150, 25);
62、 pl11.add(tfNet); tfNet.setColumns(30); final JScrollPane sPaneNet = new JScrollPane(); pl1.add(sPaneNet, BorderLayout.CENTER); JButton btnNet = new JButton("查詢"); btnNet.setFont(new Font("楷體", Font.BOLD, 14)); btnNet.addActionListener(new ActionListener() { @Ov
63、erride public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub String web = tfNet.getText(); user user2 = new user(); user2.Select_web(web, usertemp); table1 = new JTable(user2.obj,user2.columnNames); //table1.setEnabled(false); sPane
64、Net.setViewportView(table1); } }); pl11.add(btnNet); panelNet.setDividerLocation(600); panelNet.setDividerSize(1); panelNet.setResizeWeight(1); ///===========================我是華麗的分割線(>^ω^<)喵=========按賬號查詢==============================/ JPanel pl2 = new JPa
65、nel(); JPanel pr2 = new JPanel(); pl2.setLayout(new BorderLayout(0, 0)); pr2.setLayout(null); JPanel pl21 = new JPanel(); pl2.add(pl21, BorderLayout.NORTH); JPanel plMAD1 = new JPanel(); pl2.add(plMAD1, BorderLayout.SOUTH); JButton btModify1 = new JButton("修改");
66、 btModify1.setFont(new Font("楷體", Font.BOLD, 14)); JButton btDelete1 = new JButton("刪除"); btDelete1.setFont(new Font("楷體", Font.BOLD, 14)); plMAD1.add(btModify1); plMAD1.add(btDelete1); JSplitPane panelAccount = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,pl2,pr2); panelAccount.setOpaque(false); pl21.setLayout(new BoxLayout(pl21, BoxLayout.X_AXIS)); JLabel lbAccount = new JLabel("賬 號"); lbAccount.setFont(new Font("楷體", Font.BOLD, 14)); pl21.add(lbAccount);
- 溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。