?? frame.java
字號:
package GUI;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.db.*;
import FtpLocalSource.*;
import Listener.*;
/**
* 創建主窗口,
* @author 賴程遠
*
*/
public class Frame extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 主窗口構造函數
*/
public Frame()
{
initComponents();
}
// 初始化
private void initComponents()
{
// 初始化組件
panel1 = new JPanel();
panel2 = new MyPanel();
panel3 = new JPanel();
menuBar = new JMenuBar();
fileMenu = new JMenu("文件");
helpMenu = new JMenu("幫助");
newSiteMenuItem = new JMenuItem("新建站點");
exitMenuItem = new JMenuItem("退出");
aboutMenuItem = new JMenuItem("關于");
toolBar1 = new JToolBar();
connectButton = new JButton(new ImageIcon("connect.png"));
disconnectButton = new JButton(new ImageIcon("disconnect.png"));
saveSiteButton = new JButton(new ImageIcon("sitemanager.png"));
tabbedPane1 = new JTabbedPane();
tabbedPane2 = new JTabbedPane();
tabbedPane3 = new JTabbedPane();
splitPane = new JSplitPane();
sitePanel = new SitePanel();
localDirectory = new LocalSourcePanelClass();
// 布局管理
Container contentPane = this.getContentPane();
contentPane.setSize(500, 700);
contentPane.setLayout(new BorderLayout());
contentPane.add(panel1, BorderLayout.NORTH);
contentPane.add(splitPane, BorderLayout.CENTER);
contentPane.add(tabbedPane3, BorderLayout.SOUTH);
panel1.setLayout(new GridLayout(2, 0));
panel1.add(menuBar);
panel1.add(toolBar1);
menuBar.add(fileMenu);
menuBar.add(helpMenu);
fileMenu.add(newSiteMenuItem);
fileMenu.addSeparator();
fileMenu.add(exitMenuItem);
helpMenu.add(aboutMenuItem);
toolBar1.add(panel2);
toolBar1.add(panel3);
panel3.setLayout(new GridLayout(1, 3));
panel3.add(connectButton);
panel3.add(disconnectButton);
panel3.add(saveSiteButton);
splitPane.setSize(new Dimension(this.getWidth(), 100));
splitPane.setOneTouchExpandable(true);
splitPane.setLeftComponent(tabbedPane1);
splitPane.setDividerLocation(250);
splitPane.setRightComponent(tabbedPane2);
tabbedPane1.add("本地文件", localDirectory);
tabbedPane1.add("站點管理器", new JScrollPane(sitePanel));
connectButton.setToolTipText("連接");
disconnectButton.setToolTipText("斷開");
saveSiteButton.setToolTipText("保存站點");
// 顯示方式
setVisible(true);
setSize(800, 600);
setLocationRelativeTo(null);
setIconImage(new ImageIcon("tray.png").getImage());
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("OurFTP");
// 添加事件監聽
connectButton.addActionListener(new ConnectButtonListener(panel2,
localDirectory, tabbedPane2, tabbedPane3));
disconnectButton.addActionListener(new DisconnectListener(tabbedPane2,
tabbedPane3));
saveSiteButton.addActionListener(new SaveSiteButtonListener(panel2,
tabbedPane2, sitePanel));
localDirectory.getTable().addMouseListener(
(new LocalRightClickListener(tabbedPane2, localDirectory)));
SitePanelMouseHandle handle = new SitePanelMouseHandle(sitePanel,
localDirectory, tabbedPane2, tabbedPane3);
sitePanel.addMouseListener(handle);
sitePanel.getList().addMouseListener(handle);
newSiteMenuItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent arg0)
{
NewDialog newDialog = new NewDialog(sitePanel.getList());
}
});
exitMenuItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent arg0)
{
System.exit(0);
}
});
aboutMenuItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent arg0)
{
JOptionPane.showMessageDialog(null, "制作人:\n姜川,張永結,邱慶默,賴程遠");
}
});
}
// 變量聲明
// panel
private JPanel panel1;
private MyPanel panel2;
private JPanel panel3;
// menu
private JMenuBar menuBar;
private JMenu fileMenu;
private JMenu helpMenu;
private JMenuItem newSiteMenuItem;
private JMenuItem exitMenuItem;
private JMenuItem aboutMenuItem;
// toolbar
private JToolBar toolBar1;
private JButton connectButton;
private JButton disconnectButton;
private JButton saveSiteButton;
// tabbedpane
private JTabbedPane tabbedPane1;
private JTabbedPane tabbedPane2;
private JTabbedPane tabbedPane3;
// splitPane
private JSplitPane splitPane;
// external components
private SitePanel sitePanel;
private LocalSourcePanelClass localDirectory;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -