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

📄 hostchooser.java

📁 一个JAVA做的FTP软件,带源码的,可以很好的进行二次开发,,并带有详细说明文件的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            if(JFtp.localDir instanceof FilesystemConnection)            {                if(!JFtp.localDir.setPath(ltmp))                {                    if(!JFtp.localDir.setPath(System.getProperty("user.home")))                    {                        JFtp.localDir.setPath("/");                    }                }            }            int response = StartConnection.startFtpCon(htmp, utmp, ptmp,                                                       Integer.parseInt(potmp),                                                       dtmp, useLocal);            /*            con = new FtpConnection(htmp,                                    Integer.parseInt(potmp), dtmp);            //con.addConnectionListener((ConnectionListener) JFtp.localDir);            //con.addConnectionListener((ConnectionListener) JFtp.remoteDir);            //JFtp.remoteDir.setCon(con);            if (useLocal)                   JFtp.statusP.jftp.addLocalConnection(                           htmp, con);            else                   JFtp.statusP.jftp.addConnection(htmp, con);            int response = con.login(utmp, ptmp);            */            //*** START OF STUFF TO PUT INTO SEPARATE METHOD            /*            if (response!=FtpConnection.LOGIN_OK)                    tryFtpAgain(response, htmp, ptmp, utmp, potmp,                        dtmp, useLocal);            */            //*** END OF STUFF TO PUT INTO  SEPARATE METHOD            //else            //{            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));            this.dispose();            //this.setVisible(false);            JFtp.mainFrame.setVisible(true);            JFtp.mainFrame.toFront();            if(listener != null)            {                listener.componentResized(new ComponentEvent(this, 0));            }            //}        }        else if(e.getSource() == list)        {            HostList hl = new HostList(this);            FtpHost selectedHost = hl.getFtpHost();            if(selectedHost == null)            {                return;            }            host.setText(selectedHost.hostname);            pass.setText(selectedHost.password);            user.setText(selectedHost.username);            port.setText(selectedHost.port);            Settings.setProperty("jftp.useDefaultDir", true);            dirBox.setSelected(Settings.getUseDefaultDir());            lcwd.setEnabled(!dirBox.isSelected());            cwd.setEnabled(!dirBox.isSelected());        }        else if(e.getSource() == dirBox)        {            if(!dirBox.isSelected())            {                lcwd.setEnabled(true);                cwd.setEnabled(true);            }            else            {                lcwd.setEnabled(false);                cwd.setEnabled(false);            }        }        else if(e.getSource() == anonBox)        {            if(!anonBox.isSelected())            {                user.setEnabled(true);                pass.text.setEnabled(true);            }            else            {                user.setText("anonymous");                pass.setText("no@no.no");                user.setEnabled(false);                pass.text.setEnabled(false);            }        }        else if(e.getSource() == threadBox)        {            if(threadBox.isSelected())            {                dl.setEnabled(true);            }            else            {                dl.setEnabled(false);            }        }        else if(e.getSource() == backMode)        {            mode = 1;            h.setVisible(false);            ;        }        else if(e.getSource() == frontMode)        {            mode = 2;            h.setVisible(false);        }    }    /*    private void setFilesystemConnection()    {    FilesystemConnection c = new FilesystemConnection();    c.addConnectionListener(((ConnectionListener)JFtp.remoteDir));    if(!c.chdir("/")) c.chdir("C:\\");    JFtp.remoteDir.setCon(c);    }    */    private void prepareBackgroundMessage()    {        HPanel p = new HPanel();        p.add(backMode);        p.add(frontMode);        p.setLayout(new FlowLayout(FlowLayout.CENTER));        backMode.addActionListener(this);        frontMode.addActionListener(this);        h.getContentPane().setLayout(new BorderLayout(10, 10));        h.setTitle("Connection failed!");        h.setLocation(150, 200);        JTextArea text = new JTextArea();        h.getContentPane().add("Center", text);        h.getContentPane().add("South", p);        text.setText(" ---------------- Output -----------------\n\n" +                     "The server is busy at the moment.\n\n" +                     "Do you want JFtp to go to disappear and try to login\n" +                     "continuously?\n\n" +                     "(It will show up again when it has initiated a connection)\n\n");        JFtp.log.setText("");        text.setEditable(false);        h.pack();    }    public void windowClosing(WindowEvent e)    {        //System.exit(0);        this.dispose();    }    public void windowClosed(WindowEvent e)    {    }    public void windowActivated(WindowEvent e)    {    }    public void windowDeactivated(WindowEvent e)    {    }    public void windowIconified(WindowEvent e)    {    }    public void windowDeiconified(WindowEvent e)    {    }    public void windowOpened(WindowEvent e)    {    }    public Insets getInsets()    {        Insets std = super.getInsets();        return new Insets(std.top + 15, std.left + 15, std.bottom + 15,                          std.right + 15);    }    public void pause(int time)    {        try        {            Thread.sleep(time);        }        catch(Exception ex)        {        }    }    private void tryFtpAgain(int response, String htmp, String ptmp,                             String utmp, String potmp, String dtmp,                             boolean useLocal)    {        //*** FOR TESTING PURPOSES        //System.out.println(htmp + " " + ptmp + " " + utmp);        //System.out.println(potmp + " " + dtmp);        //***        if((response == FtpConnection.OFFLINE) && Settings.reconnect)        {            //FtpConnection con;            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));            h.setVisible(true);            while(mode == 0)            {                pause(10);            }            JFtp.mainFrame.setVisible(false);            while((response == FtpConnection.OFFLINE) && (mode == 1))            {                System.out.print("Server is full, next attempt in ");                int r = 5;                for(int i = 0; i < r; r--)                {                    System.out.print("" + r + "-");                    try                    {                        Thread.sleep(1000);                    }                    catch(Exception ex)                    {                    }                }                System.out.println("0...");                /* con = new                        FtpConnection(                                htmp,                                Integer.parseInt(potmp),                                dtmp);                */                //response = con.login(utmp, ptmp);                response = StartConnection.startFtpCon(htmp, utmp, ptmp,                                                       Integer.parseInt(potmp),                                                       dtmp, useLocal);            }            if(mode == 1)            {                JFtp.mainFrame.setVisible(true);            }            else            {                // Switch windows                JFtp.mainFrame.setVisible(false);                this.setVisible(true);                this.toFront();                return;            }        }        else if((response != FtpConnection.LOGIN_OK) ||                    ((response == FtpConnection.OFFLINE) &&                    (!Settings.reconnect)))        {            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));            //setFilesystemConnection();            if(useLocal)            {                JFtp.statusP.jftp.closeCurrentLocalTab();            }            else            {                JFtp.statusP.jftp.closeCurrentTab();            }            //this.setVisible(true);            //this.toFront();            return;        }    }    //*** tryFtpAgain}

⌨️ 快捷键说明

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