——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
后台管理
admin/123456
前台点餐
user1/123456







基于java的Swing餐厅在线点餐系统(管理员、用户)(java+swing+mysql)
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup( layout .createSequentialGroup() .addGap( 18, 18, 18) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( orderIdTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( jLabel5) .addComponent( jb_search)))) .addGap(23, 23, 23) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addComponent( jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap( 38, 38, 38) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| int role = currentUser.getRank(); if (role == 1) { this.dispose(); new AdminFrm().setVisible(true); } else if (role == 0) { this.dispose(); new UserOrderFrm().setVisible(true); } } else { JOptionPane.showMessageDialog(null, "用户名或密码错误"); } } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, "用户名或密码错误"); } finally { try { dbUtil.closeCon(con); } catch (Exception e) { e.printStackTrace(); } }
}
private void jb_resetActionPerformed(java.awt.event.ActionEvent evt) { this.passwordTxt.setText(""); this.userNameTxt.setText(""); }
public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new LogOnFrm().setVisible(true); } }); }
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JButton jb_logon; private javax.swing.JButton jb_register; private javax.swing.JButton jb_reset; private javax.swing.JPasswordField passwordTxt; private javax.swing.JTextField userNameTxt;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout .createSequentialGroup() .addGroup( jPanel1Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( jb_modify)) .addGroup( jPanel1Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent( jb_delete, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup( jPanel1Layout .createSequentialGroup() .addGap( 30, 30, 30) .addComponent( jb_chooser)))) .addComponent( imageLinkTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap())); jPanel1Layout .setVerticalGroup(jPanel1Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel1Layout
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| Connection con = null; try { con = dbUtil.getCon(); int deleteNum = goodsDao.goodsDelete(con, id); if (deleteNum == 1) { JOptionPane.showMessageDialog(null, "删除成功"); this.filltable(new Goods()); resetValues(); } else JOptionPane.showMessageDialog(null, "删除失败"); } catch (Exception e) {
e.printStackTrace(); JOptionPane.showMessageDialog(null, "删除失败"); } finally { try { dbUtil.closeCon(con); } catch (Exception e) { e.printStackTrace(); } }
} }
private void jb_chooserActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter( "JPG & GIF Images", "jpg", "gif"); chooser.setFileFilter(filter); int returnValue = chooser.showOpenDialog(getParent()); if (returnValue == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (file.length() / 1024.0 > 50.0) { JOptionPane.showMessageDialog(null, "请选择小于等于50KB的图片文件。"); return; } String picturePath = file.getAbsolutePath(); Icon icon = new ImageIcon(picturePath); this.iamgeLb.setIcon(icon); this.imageLinkTxt.setText(picturePath);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| jLabel1.setText("\u65b0\u7528\u6237\u6ce8\u518c");
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource( https: jLabel2.setText("\u7528\u6237\u540d\uff1a");
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource( https: jLabel3.setText("\u5bc6\u7801\uff1a");
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource( https: jLabel4.setText("\u786e\u8ba4\u5bc6\u7801\uff1a");
jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource( https: jLabel5.setText("\u90ae\u7bb1\uff1a");
jb_register.setIcon(new javax.swing.ImageIcon(getClass().getResource( https: jb_register.setText("\u6ce8\u518c"); jb_register.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jb_registerActionPerformed(evt); } });
jb_reset.setIcon(new javax.swing.ImageIcon(getClass().getResource( https: jb_reset.setText("\u91cd\u7f6e"); jb_reset.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jb_resetActionPerformed(evt); } });
javax.swing.GroupLayout layout = new javax.swing.GroupLayout( getContentPane()); getContentPane().setLayout(layout); layout .setHorizontalGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup()
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| setTitle("\u5957\u9910\u6dfb\u52a0");
jLabel2.setText("\u5957\u9910\u540d\u79f0\uff1a");
jLabel3.setText("\u5957\u9910\u4ef7\u683c\uff1a");
jLabel4.setText("\u5957\u9910\u63cf\u8ff0\uff1a");
jb_chooser.setIcon(new javax.swing.ImageIcon(getClass().getResource( https: jb_chooser.setText("\u8bf7\u9009\u62e9"); jb_chooser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jb_chooserActionPerformed(evt); } });
jPanel1.setBorder(javax.swing.BorderFactory .createTitledBorder("\u5957\u9910\u56fe\u7247"));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout( jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addContainerGap(23, Short.MAX_VALUE).addComponent(iamgeLb, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(21, 21, 21))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING).addGroup( jPanel1Layout.createSequentialGroup().addContainerGap() .addComponent(iamgeLb, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(26, Short.MAX_VALUE)));
imageLinkTxt.setEditable(false);
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=022122302612200xi
https://javayms.pages.dev?id=022122302612200xi