⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findphotoinfodialog.java

📁 数码照片管理程序是我们公司在开发过程中的用java编写的模块
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(remarkLabel)
                    .addComponent(remarkScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(exitButton)
                    .addComponent(submitButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        

private void dateRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                
// TODO add your handling code here:
    if (appointRadioButton.isSelected()) {
        appointCalendarPanel.setEnabled(true);
        comparisonComboBox.setEnabled(true);

        startCalendarPanel.setEnabled(false);
        toLabel.setEnabled(false);
        endCalendarPanel.setEnabled(false);
    } else {
        appointCalendarPanel.setEnabled(false);
        comparisonComboBox.setEnabled(false);

        startCalendarPanel.setEnabled(true);
        toLabel.setEnabled(true);
        endCalendarPanel.setEnabled(true);
    }
}                                               

private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
// TODO add your handling code here:
    String title = titleTextField.getText().trim();// 获得标题关键字

    String appointDate = appointTextField.getText();// 获得指定日期

    String spaceStartDate = startTextField.getText();// 获得开始日期

    String spaceEndDate = endTextField.getText();// 获得结束日期

    String remark = remarkTextArea.getText().trim();// 获得描述关键字

// 验证是否填写了查询条件,要求至少填写一个查询条件
    if (title.length() == 0 && remark.length() == 0) {
        if (appointRadioButton.isSelected()) {// 选中指定日期

            if (appointDate.length() == 0) {// 未填写日期

                showMessage("友情提示", "至少填写一项查找条件!");// 弹出提示信息

                return;
            }
        } else {// 选中一段时间

            if (spaceStartDate.length() == 0 || spaceEndDate.length() == 0) {// 日期填写不完整

                if (spaceStartDate.length() == 0 && spaceEndDate.length() == 0) {// 未填写日期

                    showMessage("友情提示", "至少填写一项查找条件!");// 弹出提示信息

                } else {// 日期填写不完整

                    showMessage("友情提示", "请将起止日期填写完整!");// 弹出提示信息

                }
                return;
            }
        }
    }
    final Vector<Vector> photos = new Vector<Vector>();
    if (appointRadioButton.isSelected()) {// 选中指定日期

        char compare;
        switch (comparisonComboBox.getSelectedIndex()) {
            case 1:
                compare = '>';
                break;
            case 2:
                compare = '<';
                break;
            default:
                compare = '=';
        }
        photos.addAll(dao.selectPhoto(albumId, title, appointDate, compare, remark));
    } else {// 选中一段时间

        DateFormat dateFormat = DateFormat.getDateInstance();
        Date startDate = null;
        Date endDate = null;
        try {
            startDate = dateFormat.parse(spaceStartDate);
            endDate = dateFormat.parse(spaceEndDate);
        } catch (ParseException e1) {
            showMessage("友情提示", "请将起止日期填写完整!");// 弹出提示信息

            return;

        }
        if (endDate.before(startDate)) {
            showMessage("友情提示", "终止日期不能小于起始日期!");// 弹出提示信息

            return;
        } else {
            photos.addAll(dao.selectPhoto(albumId, title, spaceStartDate, spaceEndDate, remark));
        }
    }
    final MPanel panel = (MPanel) AlbumPanel.getPhotoPanel().getComponent(0);// 获得浏览方式面板

    final JPanel photoBoxPanel = panel.getPhotoBoxPanel();// 获得图片箱面板

    photoBoxPanel.removeAll();// 移除图片箱中的所有照片

    panel.validate();// 刷新浏览方式面板

    this.dispose();// 销毁查找照片对话框

    if (photos.size() == 0) {// 没有符合条件的照片

        showMessage("查询完毕", "没有符合条件的照片!");
    } else {// 存在符合条件的照片

        new Thread() {// 创建并开启一个线程

            @Override
            public void run() {// 重构该方法

                final String filePath = FindPhotoInfoDialog.class.getResource("/img/album").getPath();// 获得存放照片的根路径

                for (Vector photo : photos) {// 遍历加载符合条件的照片

                    String albumPath = photo.get(0).toString();// 相册路径

                    int albumId = (Integer) photo.get(1);// 相册主键

                    while (true) {// 向上遍历相册至根相册

                        Vector album = dao.selectAlbum(albumId);// 获得父相册对象

                        albumId = (Integer) album.get(1);// 获得相册主键

                        albumPath = album.get(2) + "/" + albumPath;// 追加相册路径

                        if (albumId == 0) {// 已遍历至根相册

                            break;// 跳出循环

                        }
                    }
                    photoBoxPanel.add(new PhotoPreviewButton(new File(filePath + "/" + albumPath)));
                    panel.validate();// 刷新浏览方式面板

                    try {
                        Thread.sleep(600);// 休眠600毫秒

                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }.start();
        showMessage("查询完毕", "共有  " + photos.size() + "  张符合条件的照片!");// 弹出查询完毕的提示

    }
}                                            

private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
// TODO add your handling code here:
    this.dispose();
}                                          

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                FindPhotoInfoDialog dialog = new FindPhotoInfoDialog(new javax.swing.JFrame(), true, 6);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private com.mwq.album.calendar.CalendarPanel appointCalendarPanel;
    private javax.swing.JPanel appointPanel;
    private javax.swing.JRadioButton appointRadioButton;
    private javax.swing.JComboBox comparisonComboBox;
    private javax.swing.ButtonGroup dateButtonGroup;
    private javax.swing.JLabel dateLabel;
    private com.mwq.album.calendar.CalendarPanel endCalendarPanel;
    private javax.swing.JButton exitButton;
    private javax.swing.JPanel passagePanel;
    private javax.swing.JRadioButton passageRadioButton;
    private javax.swing.JLabel remarkLabel;
    private javax.swing.JScrollPane remarkScrollPane;
    private javax.swing.JTextArea remarkTextArea;
    private com.mwq.album.calendar.CalendarPanel startCalendarPanel;
    private javax.swing.JButton submitButton;
    private javax.swing.JLabel titleLabel;
    private javax.swing.JTextField titleTextField;
    private javax.swing.JLabel toLabel;
    // End of variables declaration                   
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -