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

📄 worker.java

📁 jdbc oracle jdbc oraclejdbc oraclejdbc oraclejdbc oraclejdbc oraclejdbc oracle
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        sourceTF.setPreferredSize(new Dimension(400,24));
        homePage.add(sourceTF,gbc3);
        
        SourceFileButton sfb = new SourceFileButton();
        GridBagConstraints gbc4 = new GridBagConstraints();
        gbc4.gridx = 5;
        gbc4.gridy = 1;
        homePage.add(sfb,gbc4);
        
        JLabel space = new JLabel("   ");
        GridBagConstraints gbc40 = new GridBagConstraints();
        gbc40.gridx = 5;
        gbc40.gridy = 2;
        homePage.add(space,gbc40);

        dib = new DoImportButton();
        GridBagConstraints gbc5 = new GridBagConstraints();
        gbc5.gridx = 5;
        gbc5.gridy = 3;
        homePage.add(dib,gbc5);
        
        JLabel space1 = new JLabel("                                  ");
        GridBagConstraints gbc401 = new GridBagConstraints();
        gbc401.gridx = 3;
        gbc401.gridy = 2;
        homePage.add(space1,gbc401);
        
        reButton = new ReturnButton();
        GridBagConstraints gbc6 = new GridBagConstraints();
        gbc6.gridx = 4;
        gbc6.gridy = 3;
        homePage.add(reButton,gbc6);

        javax.swing.JDesktopPane jdp = new JDesktopPane();
        jdp.setPreferredSize(new Dimension(600,200));
        jdp.setLayout(new java.awt.BorderLayout());
        jdp.add(homePage, java.awt.BorderLayout.CENTER);

        addAllMenu();

        this.setContentPane(jdp);
        jdp.setVisible(true);

        this.pack();
        this.setVisible(true);
    }
    
    class ReturnButton extends JButton implements ActionListener{
        public ReturnButton(){
            super("上一步");
            this.setVisible(false);
            addActionListener(this);
        }
        public void actionPerformed(ActionEvent e){
        	this.setVisible(false);
        	loadJComboBox(types);
        	//cancelOperation();
        }
    }

    public static void showMessage(String title, String message) {
        JOptionPane.showMessageDialog(appWindow, message, title,
                                      JOptionPane.CLOSED_OPTION);
    }

    private void addAllMenu() {
        JMenuBar jmb = new JMenuBar();

        JMenu comMenu = new JMenu("文件");

        JMenuItem M1It2 = new ExitMenu();
        comMenu.add(M1It2);

        jmb.add(comMenu);

        this.setJMenuBar(jmb);
    }

    public static void showError(String title, String message){
        JOptionPane.showMessageDialog(appWindow,message,title,JOptionPane.ERROR_MESSAGE);
    }
    class SourceFileButton extends JButton implements java.awt.event.ActionListener{
        public SourceFileButton(){
            super("浏览");
            this.addActionListener(this);
        }
        public void actionPerformed(ActionEvent e){
            chooser.setFileFilter(new MyFileFilter("可导入的数据文件"));
            chooser.setFileSelectionMode(chooser.FILES_ONLY);
            chooser.setDialogType(chooser.OPEN_DIALOG);
            chooser.setMultiSelectionEnabled(false);
            chooser.setCurrentDirectory(new File(sourceTF.getText()).getParentFile());
            //chooser.setSelectedFile(new File(sourceTF.getText()));
            int returnVal = chooser.showOpenDialog(appWindow);
            if(returnVal == JFileChooser.APPROVE_OPTION) {
                sourceTF.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    }

    class MyFileFilter extends javax.swing.filechooser.FileFilter{
        private String desc;
        private String [] accExt = {"mdb"};
        public MyFileFilter(String chooserDescription){
            desc = chooserDescription;
        }
        public boolean accept(File f){
        	for(int i = 0; i < accExt.length; i ++){
        		
        		if(f.isDirectory() || f.getName().toLowerCase().endsWith(accExt[i].toLowerCase())) return true;
        	}
            return false;
        }

        /**
         * The description of this filter. For example: "JPG and GIF Images"
         * @see FileView#getName
         */
        public String getDescription(){
            return desc;
        }
    }
    
    class ExitMenu extends JMenuItem implements ActionListener {
        public ExitMenu() {
            super("退出");
            addActionListener(this);
        }

        public void actionPerformed(ActionEvent e) {
            //if( JOptionPane.showConfirmDialog(appWindow, "Are you sure to close this application ? Data synchronize process will be stop!", "Are you sure ? ", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION){
        	doExit();
            //}
        }
    }
    
    private void doExit(){
    	if(null == currentImporter){
    		System.exit(0);
    		return;
    	}
    	if(this.currentImporter.isRunning){
	    	this.currentImporter.cancelOperation();
	    	currentImporter.exitWhenDone = true;
	    	while(this.currentImporter.isRunning){
	    		try {
					Thread.sleep(2000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
	    	}
    	}
    	System.exit(0);
    }

    public void windowClosing(WindowEvent e) {
    	doExit();
    }

    public void windowOpened(WindowEvent e) {}

    public void windowClosed(WindowEvent e) {}

    public void windowIconified(WindowEvent e) {}

    public void windowDeiconified(WindowEvent e) {}

    public void windowActivated(WindowEvent e) {}

    public void windowDeactivated(WindowEvent e) {}

    
    private void getTwo(){
    	Connection conn = null;
    	ResultSet rs = null;
    	Statement ment = null;
    	try {
    		String sql = "select SORT_ID,SUB_FOLDER,SORT_TITLE from BOOKS_SORT";
			conn = getDBConnection();
			ment  = conn.createStatement();
			rs  = ment.executeQuery(sql);
			while(rs.next()){
				list.add(new stor(rs.getInt("SORT_ID"),
								  rs.getString("SUB_FOLDER"),
								  rs.getString("SORT_TITLE")));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(null != rs){
				try {rs.close();} catch (SQLException e) {}
			}
			if(null != ment){
				try {ment.close();} catch (SQLException e) {}
			}
			if(null != conn){
				try {conn.close();} catch (SQLException e) {}
			}
			conn  = null;
		}
    }
    
    class stor{
    	stor(int id1,String folder1,String title1){
    		id  = id1;
    		folder  = folder1;
    		title  = title1;
    	}
    	int id;
    	String folder;
    	String title;
    }
    
    private static List list = new ArrayList();
    private static int sortIndex  = -1;
    
    public static int getBook_ID(){
    	return ((stor)list.get(sortIndex)).id;
    }
    
    public static String getBook_Folder(){
    	return ((stor)list.get(sortIndex)).folder;
    }
    
    private class DoImportButton extends JButton implements ActionListener{
        public DoImportButton(){
            super("下一步");
            addActionListener(this);
        }
        
        private int temp = -1;
        boolean showBookSort = false;
      
        public void actionPerformed(ActionEvent e){
        	showBookSort = false;
            int index  = jcb.getSelectedIndex();
            if(reButton.isVisible()){//分类选择>>下步
            	Debug.print("aaaaaaaaaaaaaaaaaaaaaaa = " + index);
            	if(-1 == index){
            		showError("操作错误:","馆藏珍本栏目未选择");
            		return;
            	}
            	sortIndex = index;
            	showBookSort = true;
            	showNext(temp);
            	reButton.setVisible(false);
            }else{
            	sortSelectIndex = index;
	            if(types[index].equals("馆藏珍本")){
	            	temp = index;
	            	loadBookSort();
	            }else{
	            	showNext(index);
	            }
        	}
        }
        
        public void loadBookSort(){
        	list.clear();
        	getTwo();
        	//if(/*list.size() > 0*/false){
        		String[] text  = new String[list.size()];
        		for(int i = 0; i <list.size(); i ++){
        			text[i] = ((stor)list.get(i)).title;
        			Debug.print("text[i]" + text[i]);
        		}
        		loadJComboBox(text);
        	//}
        	reButton.setVisible(true);
        	sortLable.setText("馆藏珍本栏目:");
        	sortLable.repaint();
        }
        
        private void showNext(int index){
        	 getContentPane().remove(0);
        	InterComImporter importer1 =new InterComImporter((JDesktopPane)getContentPane(),chooser.getSelectedFile());
        	importer1.setComType(index);
        	currentImporter = importer1;
        	try{
        		currentImporter.showSample();
        		appWindow.pack();
        	}catch(Exception ex){
        		ex.printStackTrace();
        		showError("系统异常",ex.getMessage());
        	}
        }
    }//end class
    
    public static void main(String[] args) {
        Worker worker = new Worker(); 
    }
}

⌨️ 快捷键说明

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