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

📄 mainwindow.java

📁 java实现的P2P多agent中间件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************
JADE - Java Agent DEvelopment Framework is a framework to develop
multi-agent systems in compliance with the FIPA specifications.
Copyright (C) 2000 CSELT S.p.A.

GNU Lesser General Public License

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation,
version 2.1 of the License.

This library 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
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA  02111-1307, USA.
*****************************************************************/

package jade.tools.sniffer;

//#DOTNET_EXCLUDE_BEGIN
import javax.swing.tree.MutableTreeNode;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Color;
import java.awt.Image;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.SwingUtilities;
//#DOTNET_EXCLUDE_END
import java.net.InetAddress;

/*#DOTNET_INCLUDE_BEGIN
import System.Windows.Forms.*;
import System.Drawing.*;
import javax.swing.*;
#DOTNET_INCLUDE_END*/

import jade.gui.AgentTree;
import jade.core.AID;
import jade.util.BasicProperties;

  /**
   Javadoc documentation for the file
   @author Francisco Regi, Andrea Soracchi - Universita` di Parma
   <Br>
   <a href="mailto:a_soracchi@libero.it"> Andrea Soracchi(e-mail) </a>
   @version $Date: 2005-11-03 10:14:43 +0100 (gio, 03 nov 2005) $ $Revision: 5809 $
 */

 /**
 * This class performs the <em>Sniffer</em> main-windows GUI setup. Also provides method for
 * asynchronous disposal at takedown.
 *
 * @see	javax.swing.JFrame
 */


public class MainWindow 
	//#DOTNET_EXCLUDE_BEGIN
	extends JFrame {
	//#DOTNET_EXCLUDE_END
	/*#DOTNET_INCLUDE_BEGIN
	extends Form {
	#DOTNET_INCLUDE_END*/

  protected MainPanel mainPanel;
  protected ActionProcessor actPro; // Making this public allows us to get directly to the sniff agent action.
  //#DOTNET_EXCLUDE_BEGIN
  private PopupMenuAgent popA;
  //#DOTNET_EXCLUDE_END
  private Sniffer mySniffer;
  private BasicProperties myProperties;
  private String snifferLogo = "images/sniffer.gif";
  /*#DOTNET_INCLUDE_BEGIN
  private System.Windows.Forms.Panel MainPanelW;
  private System.Windows.Forms.Splitter splitter2;
  private System.Windows.Forms.Panel PanelCanvasW;
  private System.Windows.Forms.Panel CanvAgentW;
  private System.Windows.Forms.Panel CanvMessW;
  private System.Windows.Forms.Panel TreePanelW;
  private System.Windows.Forms.TreeView AgentTreeW;
  protected System.Windows.Forms.TextBox textBox1;
  protected java.awt.Frame myJavaFrame	= null;
  protected PopupAgent popAg			      = null;
  protected PopupMessage popMess		    = null;
  private Message mess					        = null;
  #DOTNET_INCLUDE_END*/
   
  public MainWindow(Sniffer mySniffer, BasicProperties myProperties) {
     //#DOTNET_EXCLUDE_BEGIN
	 super(mySniffer.getName() + " - Sniffer Agent");
     //#DOTNET_EXCLUDE_END
     /*#DOTNET_INCLUDE_BEGIN
	 super();
	 #DOTNET_INCLUDE_END*/
     this.mySniffer=mySniffer;
     this.myProperties=myProperties;
     mainPanel = new MainPanel(mySniffer, this);
	 /*#DOTNET_INCLUDE_BEGIN
	 InitializeComponent();

	 mainPanel.setPanel( MainPanelW );
	 mainPanel.treeAgent.setPanel( TreePanelW );
	 mainPanel.treeAgent.tree = AgentTreeW;
	 mainPanel.treeAgent.InitializeTreeView();
	 mainPanel.panelcan.setPanel( PanelCanvasW );
	 mainPanel.panelcan.canvAgent.setPanel( CanvAgentW );
	 mainPanel.panelcan.canvMess.setPanel( CanvMessW );
	 mainPanel.textArea = textBox1;

	 set_Text( mySniffer.getName() + " - Sniffer Agent" );
	 set_ForeColor( Color.get_Black() );
	 set_BackColor( Color.get_LightGray() );
	 set_Visible( true );
	 ResumeLayout( false);
	 #DOTNET_INCLUDE_END*/

     actPro=new ActionProcessor(mySniffer,mainPanel);
     //#DOTNET_EXCLUDE_BEGIN
	 setJMenuBar(new MainMenu(this,actPro));
     popA=new PopupMenuAgent(actPro);
     setForeground(Color.black);
     setBackground(Color.lightGray);
     Image image = getToolkit().getImage(getClass().getResource(snifferLogo));
     setIconImage(image);

     addWindowListener(new WindowAdapter() {
	     public void windowClosing(WindowEvent e) {
		 MainWindow.this.mySniffer.doDelete();
	     }
     });
     mainPanel.treeAgent.setNewPopupMenu(AgentTree.AGENT_TYPE, popA);
     getContentPane().add(new ToolBar(actPro),"North");
     getContentPane().add(mainPanel,"Center");
     //#DOTNET_EXCLUDE_END
		
	 /*#DOTNET_INCLUDE_BEGIN
	 popAg = new PopupAgent(mySniffer, mainPanel.panelcan.canvAgent);
	 popMess = new PopupMessage( this );

	 System.Drawing.Point p = this.get_Location();
	 myJavaFrame = new java.awt.Frame();
	 myJavaFrame.setLocation( p.get_X(), p.get_Y() );
	 myJavaFrame.pack();
		
	 mainPanel.treeAgent.tree.set_ContextMenu( popAg );
	 mySniffer.startBehaviours();
	 
	 this.set_Menu( new MainMenuSniffer(this,actPro) );
	 this.add_Closing( new System.ComponentModel.CancelEventHandler(this.OnClosing) );
	 
	 #DOTNET_INCLUDE_END*/
 }


 public void ShowCorrect() {
  //#DOTNET_EXCLUDE_BEGIN
  pack();
  setSize(new Dimension(700,500));
  mainPanel.adjustDividerLocation();
  this.setVisible(true);
  toFront();
  //#DOTNET_EXCLUDE_END
  /*#DOTNET_EXCLUDE_BEGIN
  set_Visible( true );
  Show();
  #DOTNET_EXCLUDE_END*/
 }

 public BasicProperties getProperties() {
    return myProperties;
 }

  public void resetTree() {
	  //#DOTNET_EXCLUDE_BEGIN
      Runnable resetIt = new Runnable() {

	  public void run() {
	  //#DOTNET_EXCLUDE_END
	      mainPanel.treeAgent.clearLocalPlatform();
	  //#DOTNET_EXCLUDE_BEGIN
          }
      };
      SwingUtilities.invokeLater(resetIt);
	  //#DOTNET_EXCLUDE_END
  }

    /*#DOTNET_INCLUDE_BEGIN
  	private void InitializeComponent ()
	{
		this.MainPanelW = new System.Windows.Forms.Panel();
		this.TreePanelW = new System.Windows.Forms.Panel();
		this.AgentTreeW = new System.Windows.Forms.TreeView();
		this.PanelCanvasW = new System.Windows.Forms.Panel();
		this.CanvAgentW = new System.Windows.Forms.Panel();
		this.CanvMessW = new System.Windows.Forms.Panel();
		this.textBox1 = new System.Windows.Forms.TextBox();
		this.MainPanelW.SuspendLayout();
		this.TreePanelW.SuspendLayout();
		this.PanelCanvasW.SuspendLayout();
		this.SuspendLayout();
		// 
		// MainPanelW
		// 
		this.MainPanelW.set_Anchor(((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
			| System.Windows.Forms.AnchorStyles.Left) 
			| System.Windows.Forms.AnchorStyles.Right))));
		this.MainPanelW.set_BorderStyle(System.Windows.Forms.BorderStyle.FixedSingle);
		this.MainPanelW.get_Controls().Add(this.TreePanelW);
		this.MainPanelW.get_Controls().Add(this.PanelCanvasW);
		this.MainPanelW.get_Controls().Add(this.textBox1);
		this.MainPanelW.set_Location(new System.Drawing.Point(16, 16));
		this.MainPanelW.set_Name("MainPanelW");
		this.MainPanelW.set_Size(new System.Drawing.Size(680, 296));
		this.MainPanelW.set_TabIndex(6);
		// 
		// TreePanelW
		// 
		this.TreePanelW.get_Controls().Add(this.AgentTreeW);
		this.TreePanelW.set_Dock(System.Windows.Forms.DockStyle.Fill);
		this.TreePanelW.set_Location(new System.Drawing.Point(0, 0));
		this.TreePanelW.set_Name("TreePanelW");
		this.TreePanelW.set_Size(new System.Drawing.Size(166, 272));
		this.TreePanelW.set_TabIndex(3);
		// 
		// AgentTreeW
		// 
		this.AgentTreeW.set_BackColor(System.Drawing.SystemColors.get_Window());
		this.AgentTreeW.set_Dock(System.Windows.Forms.DockStyle.Fill);
		this.AgentTreeW.set_ImageIndex(-1);
		this.AgentTreeW.set_Location(new System.Drawing.Point(0, 0));
		this.AgentTreeW.set_Name("AgentTreeW");
		this.AgentTreeW.set_SelectedImageIndex(-1);
		this.AgentTreeW.set_Size(new System.Drawing.Size(166, 272));
		this.AgentTreeW.set_TabIndex(0);
		this.AgentTreeW.add_MouseDown( new System.Windows.Forms.MouseEventHandler(this.AgentTreeW_MouseDown) );
		// 
		// PanelCanvasW
		// 
		this.PanelCanvasW.set_AutoScroll(true);
		this.PanelCanvasW.get_Controls().Add(this.CanvAgentW);
		this.PanelCanvasW.get_Controls().Add(this.CanvMessW);
		this.PanelCanvasW.set_Dock(System.Windows.Forms.DockStyle.Right);
		this.PanelCanvasW.set_Location(new System.Drawing.Point(166, 0));
		this.PanelCanvasW.set_Name("PanelCanvasW");
		this.PanelCanvasW.set_Size(new System.Drawing.Size(512, 272));
		this.PanelCanvasW.set_TabIndex(1);
		this.PanelCanvasW.add_MouseDown( new System.Windows.Forms.MouseEventHandler(this.CanvMessW_MouseDown) );
		// 
		// CanvAgentW
		// 
		this.CanvAgentW.set_Anchor(((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
			| System.Windows.Forms.AnchorStyles.Right))));
		this.CanvAgentW.set_AutoScroll(true);
		this.CanvAgentW.set_Location(new System.Drawing.Point(0, 0));
		this.CanvAgentW.set_Name("CanvAgentW");
		this.CanvAgentW.set_Size(new System.Drawing.Size(512, 48));
		this.CanvAgentW.set_TabIndex(1);
		// 
		// CanvMessW
		// 
		this.CanvMessW.set_Anchor(((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 

⌨️ 快捷键说明

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