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

📄 basicframegui.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
/*
 *  SSL-Explorer
 *
 *  Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
 *
 *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
			
package com.sslexplorer.vpn.client;

import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class BasicFrameGUI implements VPNClientGUI {

  Image idle;
  Image tx;
  Image rx;
  Image txrx;
  Image disconnected;

  VPNClientGUIListener listener;

  ActivityPanel panel;
  Frame frame;

  public BasicFrameGUI() {

  }

  public void init(VPNClientGUIListener listener) {
    this.listener = listener;

    MenuItem open = new MenuItem("Open Browser");
    open.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        BasicFrameGUI.this.listener.open();
      }
    });

    /* DEBUG */MenuItem console = new MenuItem("Debug Console");
    /* DEBUG */console.addActionListener(new ActionListener() {
    /* DEBUG */  public void actionPerformed(ActionEvent evt) {
    /* DEBUG */    BasicFrameGUI.this.listener.console();
    /* DEBUG */  }
    /* DEBUG */});

    MenuItem ports = new MenuItem("Tunnel Monitor");
    ports.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        BasicFrameGUI.this.listener.ports();
      }
    });

    MenuItem exit = new MenuItem("Exit");
    exit.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        BasicFrameGUI.this.listener.exit();
      }
    });


   idle = ImageCanvas.loadImage(getClass(), "/images/idle.gif");
   tx = ImageCanvas.loadImage(getClass(), "/images/tx.gif");
   rx = ImageCanvas.loadImage(getClass(), "/images/rx.gif");
   txrx = ImageCanvas.loadImage(getClass(), "/images/txrx.gif");
   disconnected = ImageCanvas.loadImage(getClass(),
        "/images/disconnected.gif");

    panel = new ActivityPanel();
    panel.setBackground(Color.white);
    panel.setImage(idle);
    panel.setSize(48, 48);


    MenuBar menu = new MenuBar();
    Menu file = new Menu("File");
    /* DEBUG */file.add(console);
    file.add(open);
    file.add(ports);
    file.addSeparator();
    file.add(exit);
    menu.add(file);


    frame = new Frame("SSL-Explorer");
    frame.add(panel);
    frame.pack();
    frame.setSize(100, 100);
    frame.setMenuBar(menu);
    frame.show();

    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        BasicFrameGUI.this.listener.exit();
      }
    });
  }
  
  public void addMenuItem(final AgentAction action) {
	    MenuItem item = new MenuItem(action.getAction());
	    item.addActionListener(new ActionListener() {
	      public void actionPerformed(ActionEvent evt) {
	        action.actionPerformed();
	      }
	    });	  
  }

  public void showIdle() {
    panel.setImage(idle);
  }

  public void showDisconnected() {
    panel.setImage(disconnected);
  }

  public void showTx() {
    panel.setImage(tx);
  }

  public void showRx() {
    panel.setImage(rx);
  }

  public void showTxRx() {
    panel.setImage(txrx);
  }

  public void setInfo(String info) {
    ToolTipManager.removeToolTipText(panel.image);
    ToolTipManager.setToolTipText(panel.image, info);
  }

  class ActivityPanel extends Panel {

    ImageCanvas image;
    ActivityPanel() {
      super(new BorderLayout());
      add(image = new ImageCanvas(), BorderLayout.CENTER);
    }

    public void setImage(Image i) {
      image.setImage(i);
    }

  }

  /* (non-Javadoc)
   * @see com.sslexplorer.vpn.client.VPNClientGUI#getGUIComponent()
   */
  public Component getGUIComponent() {
    return frame;
  }


}

⌨️ 快捷键说明

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