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

📄 sftphostchooser.java

📁 JAVA FTP客户端经典
💻 JAVA
字号:
/* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */package net.sf.jftp.gui;import net.sf.jftp.gui.framework.*;import net.sf.jftp.net.*;import net.sf.jftp.config.*;import net.sf.jftp.util.*;import net.sf.jftp.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.net.*;public class SftpHostChooser extends HFrame implements ActionListener, WindowListener{    public static HTextField host = new HTextField("Host:","localhost");    public static HTextField user = new HTextField("Username:","guest");    public static HPasswordField pass = new HPasswordField("Password:","nopasswd");    private HPanel okP = new HPanel();    private HButton ok = new HButton("Connect");    private ComponentListener listener = null;    public SftpHostChooser(ComponentListener l)    {    	listener = l;	init();    }    public SftpHostChooser()    {    	init();    }    public void init()    {        setSize(500,180);        setLocation(100,150);        setTitle("Sftp Connection...");        setBackground(okP.getBackground());        getContentPane().setLayout(new GridLayout(3,2));        getContentPane().add(host);	getContentPane().add(new JLabel(""));        getContentPane().add(user);        getContentPane().add(pass);	getContentPane().add(new JLabel(""));	getContentPane().add(okP);        okP.add(ok);        ok.addActionListener(this);	setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);	pass.text.addActionListener(this);        setModal(false);        setVisible(false);	addWindowListener(this);    }    public void update() {        setVisible(true);        toFront();	host.requestFocus();    }    public void actionPerformed(ActionEvent e)    {        if(e.getSource() == ok || e.getSource() == pass.text)        {	    // Switch windows	    this.setVisible(false);	    this.setModal(false);	    JFtp.mainFrame.setVisible(true);            JFtp.mainFrame.toFront();	    SftpConnection con = null;            String htmp = host.getText().trim();            String utmp = user.getText().trim();            String ptmp = pass.getText().trim();	    try	    {	     con = new SftpConnection(htmp);	    con.setLocalPath(JFtp.localDir.getCon().getPWD());	    con.addConnectionListener((ConnectionListener) JFtp.localDir);	    con.addConnectionListener((ConnectionListener) JFtp.remoteDir);	    if(con.login(utmp,ptmp))	    {	    	if(con.chdir(con.getPWD()) || con.chdir("/"));		JFtp.remoteDir.setCon(con);	    }	    }	    catch(Exception ex)	    {	    	Log.debug("Could not create SftpConnection, does this distribution come with jcifs?");            }            this.dispose();	    if(listener != null) listener.componentResized(new ComponentEvent(this, 0));	}    }    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) {}    }}

⌨️ 快捷键说明

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