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

📄 appmenubar.java

📁 一个JAVA做的FTP软件,带源码的,可以很好的进行二次开发,,并带有详细说明文件的
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        {            connectionSelected(6);        }        else if((e.getSource() == lastConnections[7]) && (!jftp.uiBlocked))        {            connectionSelected(7);        }        else if((e.getSource() == lastConnections[8]) && (!jftp.uiBlocked))        {            connectionSelected(8);        }        else if(e.getSource() == opts)        {            AdvancedOptions adv = new AdvancedOptions();            jftp.addToDesktop("Advanced Options", adv, 500, 180);            jftp.setLocation(adv.hashCode(), 110, 180);        }        else if(e.getSource() == manage)        {            BookmarkManager m = new BookmarkManager();            JFtp.desktop.add(m, new Integer(Integer.MAX_VALUE - 10));        }        else if(marks.contains(e.getSource()))        {            ((BookmarkItem) e.getSource()).connect();        }        else if(e.getSource() == storePasswords)        {            boolean state = storePasswords.getState();            if(!state)            {                JOptionPane j = new JOptionPane();                int x = j.showConfirmDialog(storePasswords,                                            "You chose not to Save passwords.\n" +                                            "Do you want your old login data to be deleted?",                                            "Delete old passwords?",                                            JOptionPane.YES_NO_OPTION);                if(x == JOptionPane.YES_OPTION)                {                    File f = new File(Settings.login_def);                    f.delete();                    f = new File(Settings.login_def_sftp);                    f.delete();                    f = new File(Settings.login_def_nfs);                    f.delete();                    f = new File(Settings.login_def_smb);                    f.delete();                    f = new File(Settings.login);                    f.delete();                    f = new File(Settings.last_cons);                    f.delete();                    Log.debug("Deleted old login data files.\n" +                              "Please edit your bookmarks file manually!");                }            }            Settings.setProperty("jftp.security.storePasswords", state);            Settings.save();        }        //*** END OF NEW LISTENERS        else        {            String tmp = ((JMenuItem) e.getSource()).getLabel();            UIManager.LookAndFeelInfo[] m = UIManager.getInstalledLookAndFeels();            for(int i = 0; i < m.length; i++)            {                if(m[i].getName().equals(tmp))                {                    JFtp.statusP.jftp.setLookAndFeel(m[i].getClassName());                    Settings.setProperty("jftp.gui.look", m[i].getClassName());                    Settings.save();                }            }        }    }    private void show(String file)    {        java.net.URL url = ClassLoader.getSystemResource(file);        if(url == null)        {            url = HImage.class.getResource("/" + file);        }        Displayer d = new Displayer(url);        JFtp.desktop.add(d, new Integer(Integer.MAX_VALUE - 11));    }    // by jake    private void setMnemonics()    {        //*** I added accelerators for more menu items        //*** (issue: should ALL accelerators have the CTRL modifier (so that        //*** the ALT modifier is for mnemonics only?)        //*** I added mnemonics for the main menu items        file.setMnemonic('F');        opt.setMnemonic('O');        view.setMnemonic('V');        tools.setMnemonic('T');        bookmarks.setMnemonic('B');        info.setMnemonic('I');        //*** set accelerators for the remote connection window        ftpCon.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,                                                     ActionEvent.CTRL_MASK));        sftpCon.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,                                                      ActionEvent.CTRL_MASK));        smbCon.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,                                                     ActionEvent.CTRL_MASK));        nfsCon.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,                                                     ActionEvent.CTRL_MASK));        //*** IMPORTANT NOTE: Adding an accelerator for disconnecting could        //*** be something of a "gotcha" that we may not want        close.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,                                                    ActionEvent.CTRL_MASK));        //*** These next five lines can be commented out if we decide against having accelerators        //*** starting with the shift key        //*** version 1.44: we have chosen not to have shift as a modifier        //***               as we've found this is a "gotcha"        /*        localFtpCon.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,                                                          ActionEvent.SHIFT_MASK));        localSftpCon.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,                                                           ActionEvent.SHIFT_MASK));        localSmbCon.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,                                                          ActionEvent.SHIFT_MASK));        localNfsCon.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,                                                          ActionEvent.SHIFT_MASK));        closeLocalCon.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,                                                            ActionEvent.SHIFT_MASK));        */        //*** I have decided to get areound the problem by having mnemonics within the menu        //*** as accelerators. So to quickly start an FTP connection in the local window,        //*** the user can enter Alt+f+f, and Alt+f+s for SFTP,etc.        localFtpCon.setMnemonic('F');        localSftpCon.setMnemonic('S');        localSmbCon.setMnemonic('L');        localNfsCon.setMnemonic('N');        //localNfsCon.setMnemonic('N');        closeLocalCon.setMnemonic('C');        //*** and here are some other menu mnemonics I thought I'd include:        //*** (I'll add more if more are wanted)        exit.setMnemonic('X');        proxy.setMnemonic('P');        http.setMnemonic('D');        spider.setMnemonic('H');        raw.setMnemonic('T');        readme.setMnemonic('R');        todo.setMnemonic('N');        changelog.setMnemonic('C');        hp.setMnemonic('H');        opts.setMnemonic('A');        insomniac.setMnemonic('I');        manage.setMnemonic('M');        clear.setMnemonic('C');        clearItems.setMnemonic('F');        try        {            //*** end of new code section            Integer intI;            String stringI;            char charI;            for(int i = 0; i < jftp.CAPACITY; i++)            {                //*** I should note that functionality below only allows                //*** a maximum of nine connections to be remembered                //BUGFIX 1.40                //if (!(cons[i].equals("null"))) {                if(!(cons[i][0].equals("null")))                {                    intI = new Integer(i + 1);                    stringI = intI.toString();                    charI = stringI.charAt(0);                    lastConnections[i].setMnemonic(charI);                    //lastConnections[i].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));                }            }            //for        }        catch(Exception ex)        {            Log.out("WARNING: AppMenuBar produced Exception, ignored it");            ex.printStackTrace();        }    }    //setMnemonics    private void connectionSelected(int position)    {        //*** tokenize the string to extract the required data         //*** or is this the thing done elsewhere in the code,        //*** when the menu is being set up?        //String connectionInfo = cons[position];         //StringTokenizer tokens = new StringTokenizer(connectionInfo);        //StringTokenizer tokens = new StringTokenizer(cons[position], " ", false); // tab);        String protocol;        int numTokens;        String htmp = new String("");        String utmp = new String("");        String ptmp = new String("");        String dtmp = new String("");        boolean useLocal = false;        int potmp = 0;        String potmpString = new String("0");        String useLocalString = new String("false");        /*        //numTokens = tokens.countTokens();        protocol = tokens.nextToken();        htmp = tokens.nextToken();        utmp = tokens.nextToken();        ptmp = tokens.nextToken();        */        protocol = cons[position][0];        htmp = cons[position][1];        utmp = cons[position][2];        ptmp = cons[position][3];        if(ptmp.equals(""))        {            ptmp = UIUtils.getPasswordFromUser(JFtp.statusP.jftp);        }        //int j=4;        //while (cons[i][j].equals(LastConnections.SENTINEL)) {        //        j++;        //}        //usingLocal = cons[i][j-1];        /*        System.out.println(position);        System.out.println(protocol);        System.out.println(cons[position][1]);        System.out.println(cons[position][2]);        System.out.println(cons[position][3]);        */        //        if(protocol.equals("FTP"))        {            potmpString = cons[position][4];            dtmp = cons[position][5];            useLocalString = cons[position][6];            /*            potmpString = tokens.nextToken();            dtmp = tokens.nextToken();            useLocalString = tokens.nextToken();            System.out.println(potmpString);            System.out.println("FTP");            */            potmp = Integer.parseInt(potmpString);            if(useLocalString.equals("true"))            {                useLocal = true;            }            else            {                useLocal = false;            }            StartConnection.startFtpCon(htmp, utmp, ptmp, potmp, dtmp, useLocal);            //System.out.println(htmp + utmp + ptmp + potmpString +dtmp + useLocalString);          }        else if(protocol.equals("SFTP"))        {            /*                    htmp = tokens.nextToken();                    utmp = tokens.nextToken();                    ptmp = tokens.nextToken();            */            //useLocalString = tokens.nextToken();            //System.out.println("SFTP");            potmpString = cons[position][4];            useLocalString = cons[position][5];            //System.out.println(htmp + utmp + ptmp  + useLocalString);            //if (protocol == "SFTP")        }        else if(protocol.equals("NFS"))        {            useLocalString = cons[position][4];        }        else if(protocol.equals("SMB"))        {            /*            htmp = tokens.nextToken();            utmp = tokens.nextToken();            ptmp = tokens.nextToken();            */            /*            dtmp = tokens.nextToken();            useLocalString = tokens.nextToken();            */            dtmp = cons[position][4];            useLocalString = cons[position][5];            //System.out.println(htmp+utmp+ptmp+dtmp + useLocalString);        }        //***StartConnection functionality to be put in each        //***if statement        potmp = Integer.parseInt(potmpString);        if(useLocalString.equals("true"))        {            useLocal = true;        }        else        {            useLocal = false;        }        if(protocol.equals("SFTP"))        {            //BUGFIX 1.40: no longer setting port #             //to 22, now potmp            StartConnection.startCon(protocol, htmp, utmp, ptmp, potmp, dtmp,                                     useLocal);        }        else if(!(protocol.equals("FTP")))        {            //System.out.println(protocol);            StartConnection.startCon(protocol, htmp, utmp, ptmp, potmp, dtmp,                                     useLocal);        }    }    //connectionSelected}

⌨️ 快捷键说明

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