コード例 #1
0
  /** Create the panel. */
  public BusinessVehiclePanel(Vehicleblservice vehicleblservice) {
    this.setSize(1100, 664);
    this.vehicleblservice = vehicleblservice;

    initColumns();
    setViewDatas();

    DefaultTableModel model = new DefaultTableModel(getDatas(), this.columns);
    JTable table = new SingleJTable(model);
    setJTable(table);
    setTableFace();
    // 为table添加监听
    getJTable()
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent event) {
                // 当选择行时鼠标释放时才执行
                if (!event.getValueIsAdjusting()) {
                  // 如果没有选中任何一行, 则返回
                  if (getJTable().getSelectedRowCount() != 1) return;
                  view();
                }
              }
            });

    JLabel label = new JLabel("\u9009\u62E9\u8425\u4E1A\u5385");
    label.setBounds(72, 12, 60, 18);

    comboBox_query_choosebusiness = new JComboBox();
    comboBox_query_choosebusiness.setBounds(144, 7, 232, 28);
    comboBox_query_choosebusiness.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Autoquery();
          }
        });
    comboBox_showBusiness = new JComboBox();
    comboBox_showBusiness.setBounds(114, 363, 243, 28);
    addDepartment();
    JLabel label_1 = new JLabel("查询车辆编号");
    label_1.setBounds(388, 12, 72, 18);

    textField_query = new JTextField();
    textField_query.setBounds(472, 6, 295, 30);

    getAllTips();
    AutoTextFieldUtil.setupAutoComplete(textField_query, tips);
    textField_query.setColumns(10);

    JButton button_query = new JButton("查询");
    button_query.setBounds(779, 6, 93, 30);
    button_query.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            query();
          }
        });

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(6, 42, 1088, 313);

    JLabel label_2 = new JLabel("\u8F66\u8F86\u6240\u5C5E\u7684\u8425\u4E1A\u5385");
    label_2.setBounds(6, 368, 96, 18);

    JLabel label_3 = new JLabel("\u8F66\u8F86\u4EE3\u53F7");
    label_3.setBounds(6, 409, 48, 18);

    textField_vehicleNum = new JTextField();
    textField_vehicleNum.setBounds(66, 403, 174, 30);
    textField_vehicleNum.setColumns(10);

    JLabel label_4 = new JLabel("\u8F66\u724C\u53F7");
    label_4.setBounds(258, 409, 87, 18);
    label_4.setHorizontalAlignment(SwingConstants.CENTER);

    textField_license = new JTextField();
    textField_license.setBounds(357, 403, 146, 30);
    textField_license.setColumns(10);

    JLabel label_5 = new JLabel("\u8F66\u8F86\u5F00\u59CB\u670D\u5F79\u65F6\u95F4");
    label_5.setBounds(521, 409, 96, 18);

    textField_usetime = new DateTextField("yyyy-MM-dd");
    textField_usetime.setBounds(629, 403, 137, 30);
    textField_usetime.setColumns(10);

    JButton button_usetime = new JButton("\u9009\u62E9\u65F6\u95F4");
    button_usetime.setBounds(772, 403, 76, 30);
    button_usetime.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            DatePicker dp = new DatePicker(textField_usetime, Locale.CHINA);
            // previously selected date
            Date selectedDate = dp.parseDate(textField_usetime.getText());

            dp.setSelectedDate(selectedDate);
            dp.start(textField_usetime);
          }
        });

    JLabel label_6 = new JLabel("\u8F66\u8F86\u4FE1\u606F");
    label_6.setBounds(6, 445, 48, 18);

    textField_vehicleinfo = new JTextField();
    textField_vehicleinfo.setBounds(66, 445, 782, 30);
    textField_vehicleinfo.setColumns(10);

    JButton button_save = new JButton("\u4FDD\u5B58");
    button_save.setBounds(333, 487, 86, 30);
    button_save.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            save();
          }
        });

    JButton button_clear = new JButton("\u6E05\u7A7A");
    button_clear.setBounds(473, 487, 83, 30);
    button_clear.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            clear();
          }
        });

    JButton button_delete = new JButton("\u5220\u9664");
    button_delete.setBounds(628, 487, 84, 30);
    button_delete.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            delete();
          }
        });

    JButton button_showAll = new JButton("\u663E\u793A\u6240\u6709");
    button_showAll.setBounds(884, 6, 103, 30);
    button_showAll.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MainFrame.getLoglabel().setText("显示所有");
            setViewDatas();
            refreshTable();
          }
        });

    scrollPane.setViewportView(table);
    setLayout(null);
    add(label);
    add(comboBox_query_choosebusiness);
    add(label_1);
    add(textField_query);
    add(button_query);
    add(button_showAll);
    add(scrollPane);
    add(label_2);
    add(comboBox_showBusiness);
    add(label_6);
    add(textField_vehicleinfo);
    add(label_3);
    add(textField_vehicleNum);
    add(label_4);
    add(textField_license);
    add(label_5);
    add(textField_usetime);
    add(button_usetime);
    add(button_save);
    add(button_clear);
    add(button_delete);
  }
コード例 #2
0
  /** Create the panel. */
  public PaymentPanel(Paymentblservice paymentblservice) {
    this.setSize(1100, 664);
    setLayout(null);

    this.paymentblservice = paymentblservice;

    initColumns();
    setViewDatas();

    JLabel label = new JLabel("\u4ED8\u6B3E\u7C7B\u578B");
    label.setBounds(393, 370, 55, 18);
    add(label);

    String[] paymentType = {Payment.SALARY, Payment.FREIGHT, Payment.RENT, Payment.BOMUS};
    comboBox_paymentType = new JComboBox(paymentType);
    comboBox_paymentType.setBounds(477, 365, 176, 28);
    add(comboBox_paymentType);

    JLabel label_1 = new JLabel("\u4ED8\u6B3E\u65F6\u95F4");
    label_1.setBounds(393, 469, 55, 18);
    add(label_1);

    textField_paymentdatetime = new DateTextField("yyyy-MM-dd HH:mm:ss");
    textField_paymentdatetime.setBounds(477, 463, 176, 30);
    add(textField_paymentdatetime);
    textField_paymentdatetime.setColumns(10);

    JButton button = new JButton("\u9009\u62E9\u65F6\u95F4");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            DatePicker dp = new DatePicker(textField_paymentdatetime, Locale.CHINA);
            // previously selected date
            Date selectedDate = dp.parseDate(textField_paymentdatetime.getText());

            dp.setSelectedDate(selectedDate);
            dp.start(textField_paymentdatetime);
          }
        });
    button.setBounds(662, 463, 76, 30);
    add(button);

    JLabel label_2 = new JLabel("\u4ED8\u6B3E\u91D1\u989D");
    label_2.setBounds(393, 420, 55, 18);
    add(label_2);

    textField_paymentamount = new JTextField();
    textField_paymentamount.setBounds(477, 414, 176, 30);
    add(textField_paymentamount);
    textField_paymentamount.setColumns(10);

    JLabel label_3 = new JLabel("\u4ED8\u6B3E\u4EBA");
    label_3.setBounds(393, 521, 55, 18);
    add(label_3);

    comboBox_user = new JComboBox();
    addFinancer();
    comboBox_user.setBounds(477, 516, 128, 28);
    add(comboBox_user);

    JLabel label_4 = new JLabel("\u67E5\u8BE2");
    label_4.setBounds(373, 12, 55, 18);
    add(label_4);

    textField_query = new DateTextField("yyyy-MM-dd");
    textField_query.setBounds(415, 6, 251, 30);
    add(textField_query);
    textField_query.setColumns(10);

    JButton button_1 = new JButton("\u9009\u62E9\u65E5\u671F");
    button_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            DatePicker dp = new DatePicker(textField_query, Locale.CHINA);
            // previously selected date
            Date selectedDate = dp.parseDate(textField_query.getText());

            dp.setSelectedDate(selectedDate);
            dp.start(textField_query);
          }
        });
    button_1.setBounds(678, 6, 76, 30);
    add(button_1);

    JButton button_2 = new JButton("\u67E5\u8BE2");
    button_2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            query();
          }
        });
    button_2.setBounds(761, 6, 90, 30);
    add(button_2);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(6, 42, 1088, 297);
    add(scrollPane);

    DefaultTableModel model = new DefaultTableModel(getDatas(), this.columns);
    table = new SingleJTable(model);
    setJTable(table);
    setTableFace();
    // 为table添加监听
    getJTable()
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent event) {
                // 当选择行时鼠标释放时才执行
                if (!event.getValueIsAdjusting()) {
                  // 如果没有选中任何一行, 则返回
                  if (getJTable().getSelectedRowCount() != 1) return;
                  view();
                }
              }
            });

    scrollPane.setViewportView(table);

    JButton button_3 = new JButton("\u4FDD\u5B58");
    button_3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            save();
          }
        });
    button_3.setBounds(421, 596, 90, 30);
    add(button_3);

    JButton button_4 = new JButton("\u6E05\u7A7A");
    button_4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            clear();
          }
        });
    button_4.setBounds(521, 596, 90, 30);
    add(button_4);

    JButton button_5 = new JButton("\u5220\u9664");
    button_5.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            delete();
          }
        });
    button_5.setBounds(624, 596, 90, 30);
    add(button_5);

    JButton button_6 = new JButton("\u663E\u793A\u6240\u6709");
    button_6.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MainFrame.getLoglabel().setText("显示所有");
            setViewDatas();
            refreshTable();
          }
        });
    button_6.setBounds(853, 6, 90, 30);
    add(button_6);
  }