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

📄 appmenubar.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.config.Settings;import net.sf.jftp.net.*;import net.sf.jftp.util.*;import net.sf.jftp.JFtp;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class AppMenuBar extends JMenuBar implements ActionListener{ private JFtp jftp; JMenu file = new JMenu("File"); JMenu opt = new JMenu("Options"); JMenu view = new JMenu("View"); JMenu info = new JMenu("Info");  JMenu lf = new JMenu(" Switch Look & Feel to");  JMenu ftp = new JMenu(" FTP");  JMenu smb = new JMenu(" SMB");  JMenu sftp = new JMenu(" SFTP"); JMenuItem ftpCon = new JMenuItem("Connect to FTP server"); JMenuItem sftpCon = new JMenuItem("Connect to SFTP server"); JMenuItem smbCon = new JMenuItem("Browse LAN / connect to SMB server"); JMenuItem close = new JMenuItem("Disconnect and connect to Filesystem"); JMenuItem exit = new JMenuItem("Exit"); JMenuItem readme = new JMenuItem("Show readme"); JMenuItem changelog = new JMenuItem("View the changelog"); JMenuItem todo = new JMenuItem("What's next?");  JCheckBoxMenuItem resuming = new JCheckBoxMenuItem("Enable Resuming", Settings.enableResuming);  JCheckBoxMenuItem ask = new JCheckBoxMenuItem("Always ask to resume", Settings.askToResume);  JCheckBoxMenuItem smbThreads = new JCheckBoxMenuItem("Multiple connections", Settings.getEnableSmbMultiThreading());  JCheckBoxMenuItem sftpThreads = new JCheckBoxMenuItem("Multiple connections", Settings.getEnableSftpMultiThreading());  public static JCheckBoxMenuItem fadeMenu = new JCheckBoxMenuItem("Enable status animation", Settings.getEnableStatusAnimation());  public static JCheckBoxMenuItem askToDelete = new JCheckBoxMenuItem("Confirm remove", Settings.getAskToDelete()); JMenuItem clear = new JMenuItem("Clear log");public AppMenuBar(JFtp jftp){	this.jftp = jftp;	ftpCon.addActionListener(this);	close.addActionListener(this);	exit.addActionListener(this);	readme.addActionListener(this);	changelog.addActionListener(this);	todo.addActionListener(this);	resuming.addActionListener(this);	ask.addActionListener(this);	smbCon.addActionListener(this);	clear.addActionListener(this);	sftpCon.addActionListener(this);	fadeMenu.addActionListener(this);	askToDelete.addActionListener(this);	smbThreads.addActionListener(this);	sftpThreads.addActionListener(this);	clear.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));	file.add(ftpCon);	file.add(sftpCon);	file.add(smbCon);	file.addSeparator();	file.add(close);	file.addSeparator();	file.add(exit);	ftp.add(resuming);	ftp.add(ask);	smb.add(smbThreads);	sftp.add(sftpThreads);	opt.add(askToDelete);	view.addSeparator();	opt.add(ftp);	opt.add(smb);	opt.add(sftp);	view.add(fadeMenu);	view.add(clear);	view.addSeparator();	info.add(readme);	info.add(changelog);	info.add(todo);	UIManager.LookAndFeelInfo[] m  = UIManager.getInstalledLookAndFeels();	for(int i=0; i<m.length; i++)	{		JMenuItem tmp = new JMenuItem(m[i].getName());		tmp.addActionListener(this);		lf.add(tmp);	}	view.add(lf);	//UIManager.setLookAndFeel();	add(file);	add(opt);	add(view);	add(info);}    public void actionPerformed(ActionEvent e)    {        if(e.getSource() == clear)        {		jftp.clearLog();        }        else if(e.getSource() == readme)        {		show(Settings.readme);        }	else if(e.getSource() == changelog)        {		show(Settings.changelog);        }        else if(e.getSource() == todo)        {		show(Settings.todo);        }        else if(e.getSource() == exit)        {		jftp.windowClosing(null); // handles everything        }        else if(e.getSource() == close)        {		jftp.safeDisconnect();		FilesystemConnection con = new FilesystemConnection();		jftp.remoteDir.setCon(con);		con.addConnectionListener((ConnectionListener)jftp.remoteDir);		if(!con.chdir("/")) con.chdir("C:\\");	}        else if(e.getSource() == ftpCon && (!jftp.uiBlocked))        {	    jftp.safeDisconnect();            HostChooser hc = new HostChooser();            hc.toFront();	    hc.setModal(true);            hc.update();        }        else if(e.getSource() == smbCon && (!jftp.uiBlocked))        {	    jftp.safeDisconnect();	    SmbHostChooser hc = new SmbHostChooser();            hc.toFront();	    hc.setModal(true);            hc.update();        }        else if(e.getSource() == sftpCon && (!jftp.uiBlocked))        {	    jftp.safeDisconnect();	    SftpHostChooser hc = new SftpHostChooser();            hc.toFront();	    hc.setModal(true);            hc.update();        }	else if(e.getSource() == resuming)	{		boolean res = resuming.getState();		Settings.enableResuming = res;		Settings.setProperty("jftp.enableResuming", res);		ask.setEnabled(Settings.enableResuming);		Settings.save();	}	else if(e.getSource() == smbThreads)	{		Settings.setProperty("jftp.enableSmbMultiThreading", smbThreads.getState());		Settings.save();	}	else if(e.getSource() == sftpThreads)	{		Settings.setProperty("jftp.enableSftpMultiThreading", sftpThreads.getState());		Settings.save();	}	else if(e.getSource() == ask)	{		Settings.askToResume = ask.getState();	}	else if(e.getSource() == fadeMenu)	{		Settings.setProperty("jftp.gui.enableStatusAnimation", fadeMenu.getState());		Settings.save();	}	else if(e.getSource() == askToDelete)	{		Settings.setProperty("jftp.gui.askToDelete", askToDelete.getState());		Settings.save();	}	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);    }}

⌨️ 快捷键说明

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