📄 mainwindow.java
字号:
| System.Windows.Forms.AnchorStyles.Right))));
this.CanvMessW.set_AutoScroll(true);
this.CanvMessW.set_AutoScrollMinSize(new System.Drawing.Size(480, 265));
this.CanvMessW.set_Location(new System.Drawing.Point(0, 0));
this.CanvMessW.set_Name("CanvMessW");
this.CanvMessW.set_Size(new System.Drawing.Size(512, 272));
this.CanvMessW.set_TabIndex(2);
this.CanvMessW.add_DoubleClick( new System.EventHandler(this.CanvMessW_DoubleClick) );
this.CanvMessW.add_MouseDown( new System.Windows.Forms.MouseEventHandler(this.CanvMessW_MouseDown) );
//
// textBox1
//
this.textBox1.set_BackColor(System.Drawing.SystemColors.get_Control());
this.textBox1.set_Dock(System.Windows.Forms.DockStyle.Bottom);
this.textBox1.set_Font(new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((ubyte)(System.Byte)(((ubyte)0)))));
this.textBox1.set_Location(new System.Drawing.Point(0, 272));
this.textBox1.set_Name("textBox1");
this.textBox1.set_ReadOnly(true);
this.textBox1.set_Size(new System.Drawing.Size(678, 22));
this.textBox1.set_TabIndex(9);
this.textBox1.set_Text("No Message");
this.textBox1.set_TextAlign(System.Windows.Forms.HorizontalAlignment.Center);
//
// MainWindow
//
this.set_AutoScale(false);
this.set_AutoScaleBaseSize(new System.Drawing.Size(5, 13));
this.set_ClientSize(new System.Drawing.Size(712, 348));
this.get_Controls().Add(this.MainPanelW);
this.set_Font(new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((ubyte)(System.Byte)(((ubyte)0)))));
this.set_Name("MainWindow");
this.MainPanelW.ResumeLayout(false);
this.TreePanelW.ResumeLayout(false);
this.PanelCanvasW.ResumeLayout(false);
this.ResumeLayout(false);
}
#DOTNET_INCLUDE_END*/
/**
* Tells the Agent Tree to add a container.
*
* @param cont name of the container to be added
*/
public void addContainer(final String name, final InetAddress addr) {
//#DOTNET_EXCLUDE_BEGIN
Runnable addIt = new Runnable() {
public void run() {
//MutableTreeNode node = mainPanel.treeAgent.createNewNode(name,0);
//mainPanel.treeAgent.addContainerNode((AgentTree.ContainerNode)node,"FIPACONTAINER",addr);
mainPanel.treeAgent.addContainerNode(name, addr);
}
};
SwingUtilities.invokeLater(addIt);
//#DOTNET_EXCLUDE_END
/*#DOTNET_INCLUDE_BEGIN
//AgentTree.Node node = mainPanel.treeAgent.createNewNode(name,0);
//mainPanel.treeAgent.addContainerNode((AgentTree.ContainerNode)node,"FIPACONTAINER",addr);
mainPanel.treeAgent.addContainerNode(name, addr);
#DOTNET_INCLUDE_END*/
}
/**
* Tells the Agent Tree to remove a specified container.
*
* @param cont name of the container to be removed
*/
public void removeContainer(final String name) {
//#DOTNET_EXCLUDE_BEGIN
Runnable removeIt = new Runnable() {
public void run() {
mainPanel.treeAgent.removeContainerNode(name);
}
};
SwingUtilities.invokeLater(removeIt);
//#DOTNET_EXCLUDE_END
/*#DOTNET_INCLUDE_BEGIN
mainPanel.treeAgent.removeContainerNode(name);
#DOTNET_INCLUDE_END*/
}
/**
* Tells the Agent Tree to add an agent.
*
* @param cont name of the container to contain the new agent
* @param name name of the agent to be created
* @param addr address of the agent to be created
* @param comm comment (usually type of the agent)
*/
public void addAgent(final String containerName, final AID agentID) {
//#DOTNET_EXCLUDE_BEGIN
Runnable addIt = new Runnable() {
public void run() {
String agentName = agentID.getName();
//AgentTree.Node node = mainPanel.treeAgent.createNewNode(agentName, 1);
mainPanel.treeAgent.addAgentNode(agentName, "agentAddress", containerName);
//mainPanel.treeAgent.addAgentNode((AgentTree.AgentNode)node, containerName, agentName, "agentAddress", "FIPAAGENT");
}
};
SwingUtilities.invokeLater(addIt);
//#DOTNET_EXCLUDE_END
/*#DOTNET_INCLUDE_BEGIN
String agentName = agentID.getName();
//AgentTree.Node node = mainPanel.treeAgent.createNewNode(agentName, 1);
mainPanel.treeAgent.addAgentNode(agentName, "agentAddress", containerName);
//mainPanel.treeAgent.addAgentNode((AgentTree.AgentNode)node, containerName, agentName, "agentAddress", "FIPAAGENT");
#DOTNET_INCLUDE_END*/
}
/**
* Tells the Agent Tree to remove a specified agent.
*
* @param cont name of the container containing the agent
* @param name name of the agent to be removed
*/
public void removeAgent(final String containerName, final AID agentID) {
//#DOTNET_EXCLUDE_BEGIN
Runnable removeIt = new Runnable() {
public void run() {
String agentName = agentID.getName();
mainPanel.treeAgent.removeAgentNode(containerName, agentName);
mainPanel.panelcan.canvAgent.removeAgent(agentName);
mainPanel.panelcan.canvAgent.repaintNoSniffedAgent(new Agent(agentID));
}
};
SwingUtilities.invokeLater(removeIt);
//#DOTNET_EXCLUDE_END
/*#DOTNET_INCLUDE_BEGIN
String agentName = agentID.getName();
mainPanel.treeAgent.removeAgentNode(containerName, agentName);
mainPanel.panelcan.canvAgent.removeAgent(agentName);
mainPanel.panelcan.canvAgent.repaintNoSniffedAgent(new Agent(agentID));
#DOTNET_INCLUDE_END*/
}
/**
* Displays a dialog box with the error string.
*
* @param errMsg error message to print
*/
public void showError(String errMsg) {
//#DOTNET_EXCLUDE_BEGIN
JOptionPane.showMessageDialog(null, errMsg, "Error in " + mySniffer.getName(), JOptionPane.ERROR_MESSAGE);
//#DOTNET_EXCLUDE_END
/*#DOTNET_INCLUDE_BEGIN
MessageBox.Show(errMsg, "Error in " + mySniffer.getName(), MessageBoxButtons.OK, MessageBoxIcon.Error);
#DOTNET_INCLUDE_END*/
}
//#DOTNET_EXCLUDE_BEGIN
public Dimension getPreferredSize() {
return new Dimension(700,500);
}
private void setUI(String ui) {
try {
UIManager.setLookAndFeel("javax.swing.plaf."+ui);
SwingUtilities.updateComponentTreeUI(this);
pack();
} catch(Exception e){
System.out.println(e);
e.printStackTrace(System.out);
}
}
/**
enables Motif L&F
*/
public void setUI2Motif() {
setUI("motif.MotifLookAndFeel");
}
/**
enables Windows L&F
*/
public void setUI2Windows() {
setUI("windows.WindowsLookAndFeel");
}
/**
enables Multi L&F
*/
public void setUI2Multi() {
setUI("multi.MultiLookAndFeel");
}
/**
enables Metal L&F
*/
public void setUI2Metal()
{
setUI("metal.MetalLookAndFeel");
}
//#DOTNET_EXCLUDE_END
/**
* Provides async disposal of the gui to prevent deadlock when not running in
* awt event dispatcher
*/
public void disposeAsync() {
//#DOTNET_EXCLUDE_BEGIN
class disposeIt implements Runnable {
private Window toDispose;
public disposeIt(Window w) {
toDispose = w;
}
public void run() {
toDispose.dispose();
}
}
SwingUtilities.invokeLater(new disposeIt(this));
//#DOTNET_EXCLUDE_END
/*#DOTNET_INCLUDE_BEGIN
this.Close();
this.Dispose();
#DOTNET_INCLUDE_END*/
}
//#JAVA_EXCLUDE_BEGIN
/*#DOTNET_INCLUDE_BEGIN
private void AgentTreeW_MouseDown (Object sender, System.Windows.Forms.MouseEventArgs e)
{
mainPanel.treeAgent.tree.set_SelectedNode( AgentTreeW.GetNodeAt(e.get_X(), e.get_Y() ) );
TreeNode aNode = mainPanel.treeAgent.tree.get_SelectedNode();
if (e.get_Button().equals( MouseButtons.Right) && aNode.get_Nodes().get_Count() == 0)
{
Agent agent = new Agent( mainPanel.treeAgent.tree.get_SelectedNode().get_Text() );
popAg.setAgent( agent );
}
}
private void CanvMessW_MouseDown (Object sender, System.Windows.Forms.MouseEventArgs e)
{
mainPanel.panelcan.canvMess.OnMousePressed(sender, e);
mess = mainPanel.panelcan.canvMess.selMessage(e);
if (mess == null)
return;
popMess.setMessage( mess );
if ( e.get_Button().equals( MouseButtons.Right) )
{
popMess.Show(this, new Point(e.get_X(), e.get_Y() ) );
}
}
private void CanvMessW_DoubleClick (Object sender, System.EventArgs e)
{
popMess.showMessage(sender, e);
}
private void OnClosing (Object sender, System.ComponentModel.CancelEventArgs e)
{
mySniffer.doDelete();
}
#DOTNET_INCLUDE_END*/
//#JAVA_EXCLUDE_END
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -