@Override public void actionPerformed(ActionEvent e) { // 弹出对话框 // JOptionPane.showConfirmDialog(null, "choose one", "choose one", // JOptionPane.YES_NO_CANCEL_OPTION); JPanel contentPane = new JPanel(); // 创建内容面板 ArrayList<String> salerName = new ArrayList<>(); salerName.addAll(selectDao.salerNameSelect(url, user, pass)); for (String str : salerName) { JCheckBox jc = new JCheckBox(str, false); contentPane.add(jc); salerCheckBox.add(jc); } JButton sendButton = new JButton("添加"); sendButton.addActionListener(new ButtonSendMessage()); salerJF.add(contentPane, BorderLayout.CENTER); salerJF.add(sendButton, BorderLayout.SOUTH); FrameUtil.initFrame(salerJF, 400, 600); // jf.pack(); // 关闭当前窗口 salerJF.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); salerJF.setVisible(true); }
public void init() throws Exception { Properties connProp = new Properties(); connProp.load(new FileInputStream(PROP_FILE)); driver = connProp.getProperty("driver"); url = connProp.getProperty("url"); user = connProp.getProperty("user"); pass = connProp.getProperty("pass"); // 加载驱动 Class.forName(driver); // if (flag != 1) { // verticalLeft.add(saleButton); // } // verticalLeft.add(supplierButton); // verticalLeft.add(shopButton); // verticalLeft.add(departButton); // verticalLeft.add(destinationButton); // verticalLeft.add(lineButton); // verticalLeft.add(messageButton); // if (flag != 1) { // verticalLeft.add(searchButton); // } // if (flag != 1) { saleJPanel.add(saleButton); } supplierJPanel.add(supplierButton); shopJPanel.add(shopButton); departJPanel.add(departButton); destinationJPanel.add(destinationButton); lineJPanel.add(lineButton); messageJPanel.add(messageButton); if (flag != 1) { searchJPanel.add(searchButton); } verticalLeft.add(saleJPanel); verticalLeft.add(supplierJPanel); verticalLeft.add(shopJPanel); verticalLeft.add(departJPanel); verticalLeft.add(destinationJPanel); verticalLeft.add(lineJPanel); verticalLeft.add(messageJPanel); verticalLeft.add(searchJPanel); JPanel jPanel1 = new JPanel(); jPanel1.add(new JLabel("用户名:")); final JTextField salerName = new JTextField(20); jPanel1.add(salerName); JPanel jPanel2 = new JPanel(); jPanel2.add(new JLabel("电话:")); final JTextField salerPhone = new JTextField(20); jPanel2.add(salerPhone); JPanel jPanel3 = new JPanel(); jPanel3.add(new JLabel("座机:")); final JTextField salerTel = new JTextField(20); jPanel3.add(salerTel); JPanel jPanel4 = new JPanel(); jPanel4.add(new JLabel("QQ:")); final JTextField salerQQ = new JTextField(20); jPanel4.add(salerQQ); JPanel jPanel5 = new JPanel(); jPanel5.add(new JLabel("微信:")); final JTextField salerWeiXin = new JTextField(20); jPanel5.add(salerWeiXin); JPanel jPanel7 = new JPanel(); jPanel7.add(new JLabel("密码:")); final JTextField salerPassword = new JTextField(20); jPanel7.add(salerPassword); JPanel jPanel6 = new JPanel(); JButton jButton = new JButton("确认"); jPanel6.add(jButton); saleVerticalRight.add(jPanel1); saleVerticalRight.add(jPanel2); saleVerticalRight.add(jPanel3); saleVerticalRight.add(jPanel4); saleVerticalRight.add(jPanel5); saleVerticalRight.add(jPanel7); saleVerticalRight.add(jPanel6); jf.add(saleVerticalRight, BorderLayout.CENTER); jButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (adminDao.insertSale( salerName.getText(), salerPhone.getText(), salerTel.getText(), salerQQ.getText(), salerWeiXin.getText(), salerPassword.getText(), url, user, pass)) { JOptionPane.showMessageDialog(jf, "添加销售成功"); } else { JOptionPane.showMessageDialog(jf, "添加销售失败"); } } }); jf.add(verticalLeft, BorderLayout.WEST); jf.add(saleVerticalRight, BorderLayout.CENTER); FrameUtil.initFrame(jf, 500, 400); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setVisible(true); saleButton.addActionListener(new SaleInfo()); supplierButton.addActionListener(new SupplierInfo()); shopButton.addActionListener(new ShopInfo()); departButton.addActionListener(new DepartInfo()); destinationButton.addActionListener(new DesinationInfo()); lineButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { new LineController(userName).init(); } catch (Exception e1) { e1.printStackTrace(); } } }); messageButton.addActionListener(new MessageInfo(userName)); }