java酒店管理系統(tǒng)課程設(shè)計_第1頁
java酒店管理系統(tǒng)課程設(shè)計_第2頁
java酒店管理系統(tǒng)課程設(shè)計_第3頁
java酒店管理系統(tǒng)課程設(shè)計_第4頁
java酒店管理系統(tǒng)課程設(shè)計_第5頁
已閱讀5頁,還剩17頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、Java語言程序設(shè)計課程設(shè)計題目 酒店管理系統(tǒng)學(xué)院 南湖學(xué)院專業(yè) 計算機科學(xué)與技術(shù)班級 計科N112學(xué)號 學(xué)生姓名 吳威宗指導(dǎo)教師李永剛編寫日期 2014/6/26目錄一、需求分析 二、系統(tǒng)運行環(huán)境 三、功能需求描述 四、模塊結(jié)構(gòu)圖五、數(shù)據(jù)庫設(shè)計5. 1數(shù)據(jù)庫分析 5. 2數(shù)據(jù)庫概念設(shè)計5. 3數(shù)據(jù)庫邏輯結(jié)構(gòu)設(shè)計 六、程序模塊設(shè)計七、總結(jié)一、需求分析隨著餐飲行業(yè)的迅速發(fā)展,現(xiàn)有的人工管理方式已經(jīng)不能呢個滿足管理者的需求, 廣大餐飲業(yè)經(jīng)營者已經(jīng)意識到使用計算機應(yīng)用軟件的重要性,決定在餐飲企業(yè)的經(jīng)營管理上引入計算機應(yīng)用軟件管理系統(tǒng)。酒店管理系統(tǒng)的大致功能:開臺點餐菜品管理自動結(jié)賬后臺菜系菜品管理日

2、月年結(jié)賬報表用戶設(shè)置根據(jù)需求分析,本系統(tǒng)采用的語言:(1)本系統(tǒng)采用Java語言,Java是目前使用最為廣泛的計算機語言之一。它具有簡單,面向?qū)ο?,穩(wěn)定,與平臺無關(guān)等特點。說他簡單,并不是說這門語言很干癟,而是一種清楚更容易理解的方式實現(xiàn)程序。面向?qū)ο笫腔趯ο蟮淖兂筛先说乃季S方式,使人們更容易編寫程序。(2)本系統(tǒng)還采用SQL語言,SQL Server具有許多顯著優(yōu)點:易用性、適合分布組織的可伸縮性、用于決策支持的數(shù)據(jù)倉庫功能、與許多其他服務(wù)器軟件緊密關(guān)聯(lián)的集成性、良好的性價比等。(3) 本系統(tǒng)有效的利用Jav麗SQL的優(yōu)點。二、系統(tǒng)運行環(huán)境操作系統(tǒng)為 Windows 7 、 windo

3、ws XP 或 windows 2003 使用的集成開發(fā)工具 Eclipse 數(shù)據(jù)庫采用 SQLServer2008 ,項目運行環(huán)境為 JDK 7。三、功能需求描述1開臺簽單工作區(qū)的功能:主要功能有開臺、點菜、加菜、簽單、查看開臺信息和簽單信息。2自動結(jié)賬工作區(qū)的功能:一個功能是自動計算當(dāng)前選中餐臺的消費金額;另一個功能是在結(jié)賬時自動計算找零金額。3結(jié)賬報表工作區(qū)功能:日結(jié)帳報表,月結(jié)賬報表,年結(jié)賬報表。4后天管理工作區(qū)功能:管理添加信息四、模塊結(jié)構(gòu)圖模塊結(jié)構(gòu)圖五、數(shù)據(jù)庫設(shè)計5 1 數(shù)據(jù)庫分析酒店管理系統(tǒng)的需求包括開臺點菜功能、 智能化獲取菜品功能、自動結(jié)賬功能、 營業(yè)額報表功能等。 在這些功

4、能總主要涉及的數(shù)據(jù)表包括臺號表、菜品表、消費單表;為了使系統(tǒng)更加的完善,還需要為菜品分類, 即需要用到菜系表; 為了實現(xiàn)菜品的日銷售情況統(tǒng)計, 還要建立一個消費項目表,用來記錄消費單消費的菜品。5 2 數(shù)據(jù)庫概念設(shè)計數(shù)據(jù)庫設(shè)計是系統(tǒng)設(shè)計過程中的重要組成部分,它是通過管理系統(tǒng)的整天需求而制定的, 數(shù)據(jù)庫設(shè)計的好壞直接影響到系統(tǒng)的后期開發(fā)。5 3 數(shù)據(jù)庫邏輯結(jié)構(gòu)設(shè)計臺號表菜品表菜系表消費單表消費項目表管理員表六、程序模塊設(shè)計功能模塊整體設(shè)計:用戶功能界面:代碼:public class LandFrame extends JFrame private JPasswordField password

5、Field;/ 密碼框private JComboBox usernameComboBox;/ 用戶名下拉菜單public static void main(String args) try LandFrame frame = new LandFrame();frame.setVisible(true); catch (Exception e) e.printStackTrace();public LandFrame() / 首先設(shè)置窗口的相關(guān)信息super();/ 調(diào)用父類的構(gòu)造方法setTitle( 小組:吳威宗 周志遠(yuǎn) );/ 設(shè)置窗口的標(biāo)題setResizable(false);/ 設(shè)

6、置窗口不可以改變大小setAlwaysOnTop(true);/ 設(shè)置窗口總在最前方setBounds(100, 100, 428, 292);/ 設(shè)置窗口的大小setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);/ 設(shè)置當(dāng)關(guān)閉窗口時執(zhí)行的動作/ 下面將創(chuàng)建一個面板對象并添加到窗口的容器中final MPanel panel = new MPanel(this.getClass().getResource( land_background.jpg);/ 創(chuàng)建一個面板對象panel.setLayout(new GridBagLayout();/ 設(shè)置面板

7、的布局管理器為網(wǎng)格組布局 getContentPane().add(panel, BorderLayout.CENTER);/ 將面板添加到窗體中 final JLabel topLabel = new JLabel();topLabel.setPreferredSize(new Dimension(0, 126);final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints();gridBagConstraints_5.gridx = 0;gridBagConstraints_5.gridy = 0;panel.

8、add(topLabel, gridBagConstraints_5);final JLabel leftLabel = new JLabel();leftLabel.setPreferredSize(new Dimension(140, 0);final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints(); gridBagConstraints_3.gridy = 1;gridBagConstraints_3.gridx = 0;panel.add(leftLabel, gridBagConstraints_3

9、);final JLabel rightLabel = new JLabel();rightLabel.setPreferredSize(new Dimension(55, 0);final GridBagConstraints gridBagConstraints_2 = new GridBagConstraints();gridBagConstraints_2.gridy = 1;gridBagConstraints_2.gridx = 1;panel.add(rightLabel, gridBagConstraints_2);/ 創(chuàng)建并設(shè)置用戶名下拉菜單usernameComboBox

10、= new JComboBox();/ 創(chuàng)建用戶名下拉菜單組件對象 usernameComboBox.setMaximumRowCount(5);/ 設(shè)置下拉菜單最多可顯示的選項數(shù) usernameComboBox.addItem( 請選擇 );/ 為下拉菜單添加提示項 usernameComboBox.addActionListener(new UsernameComboBoxActionListener();/為下拉菜單添加事件監(jiān)聽器final GridBagConstraints gridBagConstraints = new GridBagConstraints();/創(chuàng)建網(wǎng)格組布局

11、管理器對象gridBagConstraints.anchor = GridBagConstraints.WEST;/ 設(shè)置為靠左側(cè)顯示gridBagConstraints.gridy = 1;/設(shè)置行索引為1gridBagConstraints.gridx = 2;/設(shè)置列索引為2panel.add(usernameComboBox, gridBagConstraints);/ 將組件按指定的布局管理器添加到面板 中/ 創(chuàng)建并設(shè)置密碼框passwordField = new JPasswordField();/ 創(chuàng)建密碼框組件對象passwordField.setColumns(20);/ 設(shè)

12、置密碼框可顯示的字符數(shù)passwordField.setText( );/ 設(shè)置密碼框默認(rèn)顯示6 個空格passwordField.addFocusListener(new PasswordFieldFocusListener();/ 為密碼框添加焦點監(jiān)聽 器final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints();/ 創(chuàng)建網(wǎng)格組布局管理器對象gridBagConstraints_1.insets = new Insets(5, 0, 0, 0);/ 設(shè)置組件外部上方的填充量為 5 像素 gridBagCo

13、nstraints_1.anchor = GridBagConstraints.WEST;/ 設(shè)置為靠左側(cè)顯示 gridBagConstraints_1.gridy = 2;/設(shè)置行索引為2gridBagConstraints_1.gridx = 2;/設(shè)置列索引為2panel.add(passwordField, gridBagConstraints_1);/ 將組件按指定的布局管理器添加到面板中 / 創(chuàng)建并設(shè)置一個用來添加三個按鈕的面板final JPanel buttonPanel = new JPanel();/ 創(chuàng)建一個用來添加按鈕的面板buttonPanel.setOpaque(f

14、alse);/ 設(shè)置面板的背景為透明buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS);/ 設(shè)置面板采用水 平箱布局final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints();/ 創(chuàng)建網(wǎng)格組布局 管理器對象gridBagConstraints_4.insets = new Insets(10, 0, 0, 0);/ 設(shè)置組件外部上方的填充量為10 像素gridBagConstraints_4.gridwidth = 2;/ 設(shè)置

15、其占兩列g(shù)ridBagConstraints_4.gridy = 3;/設(shè)置行索引為3gridBagConstraints_4.gridx = 1;/設(shè)置列索引為1panel.add(buttonPanel, gridBagConstraints_4);/ 將組件按指定的布局管理器添加到面板中/ 創(chuàng)建并設(shè)置一個登錄按鈕,并將其添加到用來添加按鈕的面板中final JButton landButton = new JButton();/ 創(chuàng)建登錄按鈕組件對象landButton.setMargin(new Insets(0, 0, 0, 0);/ 設(shè)置按鈕邊框和標(biāo)簽之間的間隔landButton

16、.setContentAreaFilled(false);/ 設(shè)置不繪制按鈕的內(nèi)容區(qū)域landButton.setBorderPainted(false);/ 設(shè)置不繪制按鈕的邊框URL landUrl = this.getClass().getResource(land_submit.png);/ 獲得默認(rèn)情況下登錄按鈕顯示圖片的 URLlandButton.setIcon(new ImageIcon(landUrl);/ 設(shè)置默認(rèn)情況下登錄按鈕顯示的圖片URL landOverUrl = this.getClass().getResource(land_submit_over.png);/

17、 獲得當(dāng)鼠標(biāo)經(jīng)過登錄按鈕時顯示圖片的 URLlandButton.setRolloverIcon(new ImageIcon(land_submit_over.png);/ 設(shè)置當(dāng)鼠標(biāo)經(jīng)過登錄按鈕時顯示的圖片URL landPressedUrl = this.getClass().getResource(land_submit_pressed.png);/ 獲得當(dāng)?shù)卿洶粹o被按下時顯示圖片的 URLlandButton.setPressedIcon(new ImageIcon(land_submit_pressed.png);/ 設(shè)置當(dāng)?shù)卿洶粹o被按下時顯示的圖片landButton.addAct

18、ionListener(new LandButtonActionListener();/ 為登錄按鈕添加事件監(jiān)聽器buttonPanel.add(landButton);/ 將登錄按鈕添加到用來添加按鈕的面板中final JButton resetButton = new JButton();resetButton.setMargin(new Insets(0, 0, 0, 0);resetButton.setContentAreaFilled(false);resetButton.setBorderPainted(false);URL resetUrl = this.getClass().g

19、etResource(land_reset.png);resetButton.setIcon(new ImageIcon(resetUrl);URL resetOverUrl = this.getClass().getResource(land_reset_over.png);resetButton.setRolloverIcon(new ImageIcon(land_reset_over.png);URL resetPressedUrl = this.getClass().getResource(land_reset_pressed.png);resetButton.setPressedIc

20、on(new ImageIcon(resetPressedUrl);resetButton.addActionListener(new ResetButtonActionListener();buttonPanel.add(resetButton);final JButton exitButton = new JButton();exitButton.setMargin(new Insets(0, 0, 0, 0);exitButton.setContentAreaFilled(false);exitButton.setBorderPainted(false);URL exitUrl = th

21、is.getClass().getResource(land_exit.png);exitButton.setIcon(new ImageIcon(exitUrl);URL exitOverUrl = this.getClass().getResource(land_exit_over.png);exitButton.setRolloverIcon(new ImageIcon(exitOverUrl);URL exitPressedUrl = this.getClass().getResource(land_exit_pressed.png);exitButton.setPressedIcon

22、(new ImageIcon(exitPressedUrl); exitButton.addActionListener(new ExitButtonActionListener();buttonPanel.add(exitButton);/ 初始化用戶名下拉菜單Vector userNameV = Dao.getInstance().sUserNameOfNotFreeze();if (userNameV.size() = 0) usernameComboBox.addItem(TSoft); else for (int i = 0; i userNameV.size(); i+) user

23、nameComboBox.addItem(userNameV.get(i);class UsernameComboBoxActionListener implements ActionListener public void actionPerformed(ActionEvent e) String userName = (String) usernameComboBox.getSelectedItem();if (userName.equals(TSoft) passwordField.setText(111);class PasswordFieldFocusListener impleme

24、nts FocusListener public void focusGained(FocusEvent e) passwordField.setText();public void focusLost(FocusEvent e) char passwords = passwordField.getPassword();String password = turnCharsToString(passwords);if (password.length() = 0) passwordField.setText( );class ExitButtonActionListener implement

25、s ActionListener public void actionPerformed(ActionEvent arg0) System.exit(0);class ResetButtonActionListener implements ActionListener public void actionPerformed(ActionEvent arg0) usernameComboBox.setSelectedIndex(0);passwordField.setText( );class LandButtonActionListener implements ActionListener

26、 public void actionPerformed(ActionEvent e) String username = usernameComboBox.getSelectedItem().toString();/ 獲得登錄用戶的名 稱if (username.equals( 請選擇 ) / 查看是否選擇了登錄用戶JOptionPane.showMessageDialog(null, 請選擇登錄用戶! , 友情提示 , JOptionPane.INFORMATION_MESSAGE);/ 彈出提示 resetUsernameAndPassword();/ 恢復(fù)登錄用戶和登錄密碼 char

27、passwords = passwordField.getPassword();/ 獲得登錄用戶的密碼 String inputPassword = turnCharsToString(passwords);/ 將密碼從 char 型數(shù)組轉(zhuǎn)換成字符 串if (username.equals(JAVA) / 查看是否為默認(rèn)用戶登錄if (inputPassword.equals(123456) / 查看密碼是否為默認(rèn)密碼 land(null);/ 登錄成功String infos = 請立刻單擊“用戶管理”按鈕添加用戶! , 添加用戶后需要重新登錄,本系統(tǒng)才能正常使用! ;/ 組織提示 信息JO

28、ptionPane.showMessageDialog(null, infos, 友情提示 , JOptionPane.INFORMATION_MESSAGE);/ 彈出提示 else / 密碼錯誤JOptionPane.showMessageDialog(null, 默認(rèn)用戶“ TSoft ”的登錄密碼為“ 111 ”! , 友情提示 , JOptionPane.INFORMATION_MESSAGE);/ 彈出提示passwordField.setText(111);/ 將密碼設(shè)置為默認(rèn)密碼 else if (inputPassword.length() = 0) / 用戶未輸入登錄密碼J

29、OptionPane.showMessageDialog(null, 請輸入登錄密碼! , 友情提示 , JOptionPane.INFORMATION_MESSAGE);/ 彈出提示 resetUsernameAndPassword();/ 恢復(fù)登錄用戶和登錄密碼 Vector user = Dao.getInstance().sUserByName(username);/ 查詢登錄用戶String password = user.get(5).toString();/ 獲得登錄用戶的密碼 if (inputPassword.equals(password) / 查看登錄密碼是否正確 lan

30、d(user);/ 登錄成功 else / 登錄密碼錯誤JOptionPane.showMessageDialog(null, 登錄密碼錯誤,請確認(rèn)后重新登錄! 友情提示 , JOptionPane.INFORMATION_MESSAGE);/ 彈出提示 resetUsernameAndPassword();/ 恢復(fù)登錄用戶和登錄密碼 private void resetUsernameAndPassword() / 恢復(fù)登錄用戶和登錄密碼usernameComboBox.setSelectedIndex(0);/ 恢復(fù)選中的登錄用戶為“請選擇”項);/ 恢復(fù)密碼框的默認(rèn)值為 6 個空格pas

31、swordField.setText(return;/ 直接返回private void land(Vector user) / 登錄成功TipWizardFrame tipWizard = new TipWizardFrame(user);/ 創(chuàng)建主窗體對象 tipWizard.setVisible(true);/ 設(shè)置主窗體可見 setVisible(false);/ 設(shè)置登錄窗口不可見private String turnCharsToString(char chars) StringBuffer strBuf = new StringBuffer();for (int i = 0; i

32、 chars.length; i+) strBuf.append(charsi);return strBuf.toString().trim();數(shù)據(jù)庫連接代碼:public class JDBC private String dbUserName=root;private String dbPassword=123456;/*獲取數(shù)據(jù)庫連接*/public Connection getCon() throws ExceptionClass.forName(jdbcName);Connection con=DriverManager.getConnection(JDBC, dbUserName

33、,dbPassword); return con;/*關(guān)閉數(shù)據(jù)庫連接*/public void closeCon(Connection con) throws Exception if(con!=null)con.close();public static void main(Stringargs)JDBC JDBC =new JDBC() ;try JDBC.getCon(); catch (Exception e) / TODO Auto-generated catch blocke.printStackTrace();public static Connection getConnect

34、ion() / TODO Auto-generated method stub return null;日期類代碼:package importpublicclassToday privatestaticfinal Calendar NOW= Calendar. getInstance ();privatestaticfinal int YEAR = NOW.get(Calendar.YEAR);privatestaticfinal int MONTH= NOW.get(Calendar.MONTH) + 1;privatestaticfinal int DAY = NOW.get(Calen

35、dar.DAY_OF_MONTH);privatestaticfinal int WEEK= NOW.get(Calendar.DAY_OF_WEEK);privatestaticfinal int HOUR= NOW.get(Calendar.HOUR_OF_DAY);privatestaticfinal int MINUTE = NOW.get(Calendar.MINUTE);privatestaticfinal int SECOND= NOW.get(Calendar.SECOND);/publicstaticString getDate() return YEAR+ MONTH+ D

36、AY;String getDateOfNum() YEAR+ ;public staticString y =String m =String d =MONTH+ ;DAY + ;if ( MONTH 10)m = 0 + MONTH;if ( DAY 10)d = 0 + DAY;return y + m + d;public static String getDateOfShow() return YEAR+ 年 + MONTH+ 月 + DAY+ 日 ;public static String getDayOfWeek() String dayOfWeek = switch ( WEEK

37、) dayOfWeek = 星期日 ;break ;dayOfWeek = 星期一 ;break ;dayOfWeek = 星期二 ;break ;dayOfWeek = 星期三 ;break ;dayOfWeek = 星期四 ;break ;dayOfWeek = 星期五 ;dayOfWeek = 星期六 ;break ;return dayOfWeek; public static String getTime() return HOUR+ : + MINUTE + : + SECOND; public static void main(String args) System. out .

38、println(Today. getDayOfWeek (); public static int getYEAR() return YEAR; public static int getDAY() return DAY;public static int getMONTH() return MONTH; 利用正則表達(dá)式驗證數(shù)據(jù)合法性的方法代碼:public class Validate public static boolean execute(String rule, String content) Pattern pattern = Ppile(rule);/利用驗證規(guī)則創(chuàng)建 Patte

39、rn 對象Matcher matcher = pattern.matcher(content);/利用驗證內(nèi)容獲得 Matcher 對象return matcher.matches();/返回驗證結(jié)果 按鈕類:public class MButton extends JButton public MButton() setContentAreaFilled(false);setMargin(new Insets(0, 0, 0, 0);setBorderPainted(false);setFocusPainted(false);表格類:public class MTable extends J

40、Table /*/public MTable() super();public MTable(DefaultTableModel tableModel) super(tableModel);/ 表格列值居中顯示Overridepublic TableCellRenderer getDefaultRenderer(Class columnClass) / 獲得除表格頭部分的單元格對象DefaultTableCellRenderer tableRenderer = (DefaultTableCellRenderer) super .getDefaultRenderer(columnClass);/

41、 設(shè)置單元格內(nèi)容居中顯示tableRenderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER); return tableRenderer;/ 表格列名信息Overridepublic JTableHeader getTableHeader() / 獲得表格頭對象JTableHeader tableHeader = super.getTableHeader();tableHeader.setReorderingAllowed(false);/設(shè)置表格列不可重排/ 獲得表格頭的單元格對象DefaultTableCellRende

42、rer headerRenderer = (DefaultTableCellRenderer) tableHeader .getDefaultRenderer();/ 設(shè)置單元格內(nèi)容(即列名)居中顯示headerRenderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);return tableHeader;public void setRowSelectionInterval(int i) / TODO Auto-generated method stub圖片類:public class MPanel extends JP

43、anel private ImageIcon imageIcon;/ 聲明一個圖片對象public MPanel(URL imgUrl) super();/ 繼承父類的構(gòu)造方法setLayout(new GridBagLayout();/ 將布局管理器修改為網(wǎng)格組布局imageicon = new Imagelcon(imgUrl);/根據(jù)傳入的 URL創(chuàng)建 Imageicon 對象setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight();/設(shè)置面板與圖片等大protected void paintComponent(Graphic

44、s g) /重寫 JPanel 類的 paintComponent() 方法super.paintComponent(g);/ 調(diào)用 JPanel 類的 paintComponent() 方法 image image = imageicon.getimage();/通過 imageicon 對象獲得image 對象g.drawimage(image, 0, 0, null);/繪制 image 對象,即將圖片繪制到面板中修改密碼對話框:public class UpdatePasswordDialog extends JDialog private JPasswordField oldPass

45、wordField;private JPasswordField repeatPasswordField;private JPasswordField newPasswordField;private final Dao dao = Dao.getinstance();private Vector user;/*Launch the application*param args/public static void main(String args) try UpdatePasswordDialog dialog = new UpdatePasswordDialog(); dialog.add

46、WindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); );dialog.setVisible(true); catch (Exception e) e.printStackTrace();/* Create the dialog*/public UpdatePasswordDialog() super();getContentPane().setLayout(new GridBagLayout();setModal(true);setTitle( 修改密碼 );Di

47、mension screenSize = Toolkit.getDefaultToolkit().getScreenSize();setBounds(screenSize.width - 300) / 2, (screenSize.height - 200) / 2,300, 200);final JLabel oldPasswordLabel = new JLabel();oldPasswordLabel.setText( 原 密 碼: );final GridBagConstraints gridBagConstraints_7 = new GridBagConstraints();gri

48、dBagConstraints_7.gridx = 0;gridBagConstraints_7.gridy = 0;getContentPane().add(oldPasswordLabel, gridBagConstraints_7);oldPasswordField = new JPasswordField();oldPasswordField.setText( );oldPasswordField.addFocusListener(new FocusListener() public void focusGained(FocusEvent e) oldPasswordField.set

49、Text();public void focusLost(FocusEvent e) char passwords = oldPasswordField.getPassword();String password = turnCharsToString(passwords);if (password.length() = 0) oldPasswordField.setText( ););oldPasswordField.setColumns(25);final GridBagConstraints gridBagConstraints_8 = new GridBagConstraints();

50、gridBagConstraints_8.gridwidth = 3;gridBagConstraints_8.gridy = 0;gridBagConstraints_8.gridx = 1;getContentPane().add(oldPasswordField, gridBagConstraints_8);final JLabel newPasswordLabel = new JLabel();newPasswordLabel.setText( 新 密 碼: );final GridBagConstraints gridBagConstraints = new GridBagConst

51、raints(); gridBagConstraints.insets = new Insets(10, 0, 0, 0);gridBagConstraints.gridy = 1;gridBagConstraints.gridx = 0;getContentPane().add(newPasswordLabel, gridBagConstraints);newPasswordField = new JPasswordField();newPasswordField.setText( );newPasswordField.addFocusListener(new FocusListener()

52、 public void focusGained(FocusEvent e) newPasswordField.setText();public void focusLost(FocusEvent e) char passwords = newPasswordField.getPassword();String password = turnCharsToString(passwords);if (password.length() = 0) newPasswordField.setText( ););newPasswordField.setColumns(25);final GridBagC

53、onstraints gridBagConstraints_1 = new GridBagConstraints(); gridBagConstraints_1.insets = new Insets(10, 0, 0, 0);gridBagConstraints_1.gridwidth = 3;gridBagConstraints_1.gridy = 1;gridBagConstraints_1.gridx = 1;getContentPane().add(newPasswordField, gridBagConstraints_1);final JLabel repeatPasswordL

54、abel = new JLabel();repeatPasswordLabel.setText( 重新輸入: );final GridBagConstraints gridBagConstraints_2 = new GridBagConstraints(); gridBagConstraints_2.insets = new Insets(10, 0, 0, 0);gridBagConstraints_2.gridy = 2;gridBagConstraints_2.gridx = 0;getContentPane().add(repeatPasswordLabel, gridBagCons

55、traints_2);repeatPasswordField = new JPasswordField();repeatPasswordField.setText( );repeatPasswordField.addFocusListener(new FocusListener() public void focusGained(FocusEvent e) repeatPasswordField.setText();public void focusLost(FocusEvent e) char passwords = repeatPasswordField.getPassword();Str

56、ing password = turnCharsToString(passwords);if (password.length() = 0) repeatPasswordField.setText( ););repeatPasswordField.setColumns(25);final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints();gridBagConstraints_3.gridwidth = 3;gridBagConstraints_3.insets = new Insets(10, 0, 0, 0)

57、;gridBagConstraints_3.gridy = 2;gridBagConstraints_3.gridx = 1;getContentPane().add(repeatPasswordField, gridBagConstraints_3);final JLabel label = new JLabel();label.setPreferredSize(new Dimension(30, 20);final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();gridBagConstraints_6.

58、gridy = 3;gridBagConstraints_6.gridx = 1;getContentPane().add(label, gridBagConstraints_6);final JButton submitButton = new JButton();submitButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) char oldPasswords = oldPasswordField.getPassword();String oldPassword =

59、 turnCharsToString(oldPasswords);char newPasswords = newPasswordField.getPassword();String newPassword = turnCharsToString(newPasswords);char repeatPasswords = repeatPasswordField.getPassword();String repeatPassword = turnCharsToString(repeatPasswords);if (oldPassword.length() = 0 | newPassword.leng

60、th() = 0| repeatPassword.length() = 0) JOptionPane.showMessageDialog(null, 請輸入密碼! , 友情提示 ,JOptionPane.INFORMATION_MESSAGE);oldPasswordField.setText( );newPasswordField.setText( );repeatPasswordField.setText( ); return;String password = user.get(5).toString();if (oldPassword.equals(password) if (newP

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論