📄 mainframe.java
字号:
/*****************************************************************
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 demo.MeetingScheduler;
import java.awt.*;
import java.util.*;
import java.util.*;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import jade.core.Agent;
import jade.core.AID;
import jade.domain.FIPAAgentManagement.*;
import demo.MeetingScheduler.Ontology.*;
import javax.swing.*;
import javax.swing.event.*;
import jade.gui.GuiEvent;
import CalendarBean.JCalendar;
import java.beans.*;
import java.text.*;
import java.text.DateFormat;
import java.util.EventListener;
/**
Javadoc documentation for the file
@author Fabio Bellifemine-Alberto Adorni-Luca Grulla-Gabriele Torelli
@version $Date: 2004-07-09 12:40:50 +0200 (ven, 09 lug 2004) $ $Revision: 5199 $
*/
public class mainFrame extends JFrame {
MeetingSchedulerAgent myAgent;
int currentAction; // indicates the action currently being executed
final static int VIEWKNOWNPERSONS = 0;
final static int VIEWKNOWNDF = 1;
public mainFrame(MeetingSchedulerAgent a, String title) {
this(title);
myAgent = a;
}
class Lis implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent e) {
calendar1_Action();
}
}
class NameListener implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
listNames_ItemStateChanged();
}
}
public mainFrame() {
//{{INIT_CONTROLS
java.util.Locale.setDefault(Locale.US);
getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.Y_AXIS));
getContentPane().setVisible(true);
setSize(300,400);
//pannello contenente la schermata principale
p2=new JPanel();
p2.setLayout(new BoxLayout(p2,BoxLayout.Y_AXIS));
getContentPane().add(p2);
p2.setVisible(true);
p2.add(Box.createRigidArea(new Dimension(0,25)));
calendar1 = new JCalendar();
calendar1.setFont(new Font("Dialog", Font.BOLD, 10));
calendar1.addPropertyChangeListener(new Lis());
calendarPanel = new JPanel();
calendarPanel.setLayout(new BoxLayout(calendarPanel , BoxLayout.X_AXIS));
calendarPanel.add(Box.createRigidArea(new Dimension(15,0)));
calendarPanel.add(calendar1);
calendarPanel.add(Box.createRigidArea(new Dimension(15,0)));
p2.add(calendarPanel);
p2.add(Box.createRigidArea(new Dimension(0,10)));
//area di note sugli appuntamenti
description=new JLabel("Appointment Description");
description.setAlignmentX(JComponent.CENTER_ALIGNMENT);
p2.add(description);
p2.add(Box.createRigidArea(new Dimension(0,5)));
descriptionPanel = new JPanel();
descriptionPanel.setLayout(new BoxLayout(descriptionPanel,BoxLayout.X_AXIS));
descriptionPanel.add(Box.createRigidArea(new Dimension(15,0)));
textArea1 = new JTextArea("",3,0);
textArea1.setEditable(false);
textArea1.setLineWrap(true);
textArea1.setAlignmentX(JComponent.CENTER_ALIGNMENT);
//dimensione TextArea descrizione appuntamenti
textArea1.setMinimumSize(new Dimension(100,20));
textArea1.setPreferredSize(new Dimension(700,80));
textArea1.setMaximumSize(new Dimension(700,80));
descriptionPanel.add(textArea1);
descriptionPanel.add(Box.createRigidArea(new Dimension(15,0)));
p2.add(descriptionPanel);
//pannello *register with a facilitator*
facFrame = new JFrame();
facFrame.setVisible(false);
facFrame.setSize(400,150);
p1=new JPanel();
p1.setLayout(new BoxLayout(p1,BoxLayout.Y_AXIS));
facFrame.getContentPane().add(p1);
p1.setVisible(true);
p1.add(Box.createRigidArea(new Dimension(0,20)));
labelInsertDF = new JLabel("Insert agent address of the DF");
labelInsertDF.setVisible(true);
labelInsertDF.setAlignmentX(CENTER_ALIGNMENT);
labelInsertDF.setFont(new Font("Dialog", Font.BOLD, 12));
p1.add(labelInsertDF);
p1.add(Box.createRigidArea(new Dimension(0,10)));
textFieldDFaddress = new JTextField(80);
textFieldDFaddress.setVisible(true);
textFieldDFaddress.setMinimumSize(new Dimension(100,25));
textFieldDFaddress.setPreferredSize(new Dimension(100,25));
textFieldDFaddress.setMaximumSize(new Dimension(200,25));
textFieldDFaddress.setAlignmentX(CENTER_ALIGNMENT);
p1.add(textFieldDFaddress);
p1.add(Box.createRigidArea(new Dimension(0,20)));
facilitatorMessage = new JLabel("Press Enter when done");
facilitatorMessage.setAlignmentX(JComponent.CENTER_ALIGNMENT);
p1.add(facilitatorMessage);
p1.add(Box.createRigidArea(new Dimension(0,20)));
//pannello di *view known facilitator* e *view known persons*
knowFrame = new JFrame();
knowFrame.setVisible(false);
// knowFrame.setTitle("view known");
knowFrame.setSize(450,400);
p3=new JPanel();
p3.setLayout(new BoxLayout(p3,BoxLayout.Y_AXIS));
p3.setVisible(true);
knowFrame.getContentPane().add(p3);
p3.add(Box.createRigidArea(new Dimension(0,20)));
description=new JLabel();
description.setVisible(true);
description.setAlignmentX(JComponent.CENTER_ALIGNMENT);
p3.add(description);
knowFrame.setTitle("view known "+description.getText());
p3.add(Box.createRigidArea(new Dimension(0,10)));
textArea2=new JTextArea("",0,0);
textArea2.setVisible(true);
textArea2.setLineWrap(true);
textArea2.setEditable(false);
persPanel = new JPanel();
persPanel.setLayout(new BoxLayout(persPanel , BoxLayout.X_AXIS));
persPanel.add(Box.createRigidArea(new Dimension(15,0)));
persPanel.add(textArea2);
persPanel.add(Box.createRigidArea(new Dimension(15,0)));
p3.add(persPanel);
p3.add(Box.createRigidArea(new Dimension(0,35)));
lModel = new DefaultListModel();
listNames = new JList(lModel);
//listNames.setMinimumSize(new Dimension(100,100));
listNames.setFixedCellWidth(100);
listNames.setVisibleRowCount(4);
sPane = new JScrollPane(listNames , ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS , ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
sPane.setVisible(true);
//getContentPane().add(listNames);
listPanel = new JPanel();
listPanel.setLayout(new BoxLayout(listPanel , BoxLayout.X_AXIS));
listPanel.add(Box.createRigidArea(new Dimension(15,0)));
listPanel.add(sPane);
listPanel.add(Box.createRigidArea(new Dimension(15,0)));
p3.add(listPanel);
p3.add(Box.createRigidArea(new Dimension(0,20)));
doneButton = new JButton("Done");
doneButton.setAlignmentX(JComponent.CENTER_ALIGNMENT);
doneButton.addActionListener(new SymAction());
p3.add(doneButton);
p3.add(Box.createRigidArea(new Dimension(0,20)));
//pannello riportante le Infomrmazioni di sistema
p4=new JPanel();
p4.setLayout(new BoxLayout(p4,BoxLayout.Y_AXIS));
p4.setVisible(true);
getContentPane().add(p4);
p4.add(Box.createRigidArea(new Dimension(0,20)));
LInfo=new JLabel("Information");
LInfo.setAlignmentX(JComponent.CENTER_ALIGNMENT);
p4.add(LInfo);
infoPanel = new JPanel();
infoPanel.setLayout(new BoxLayout(infoPanel , BoxLayout.X_AXIS));
infoPanel.add(Box.createRigidArea(new Dimension(10,0)));
Info=new JTextField();
Info.setVisible(true);
Info.setEditable(false);
Info.setFont(new Font("Dialog", Font.ITALIC, 10));
Info.setForeground(new Color(0));
Info.setBackground(new Color(16776960));
Info.setAlignmentX(JComponent.CENTER_ALIGNMENT);
infoPanel.add(Info);
infoPanel.add(Box.createRigidArea(new Dimension(10,0)));
p4.add(infoPanel);
p4.add(Box.createRigidArea(new Dimension(0,10)));
getContentPane().add(Box.createVerticalGlue());
//{{INIT_MENUS
mainMenuBar = new JMenuBar();
menu1 = new JMenu("Directory");
miRegWithDF = new JMenuItem("Register with a Facilitator");
menu1.add(miRegWithDF);
miViewDF = new JMenuItem("View Known Facilitators");
menu1.add(miViewDF);
menuItem3 = new JMenuItem("View Known Persons");
menu1.add(menuItem3);
menuItem4 = new JMenuItem("Update Known Persons with the Facilitators");
menu1.add(menuItem4);
mainMenuBar.add(menu1);
appMenu = new JMenu("Appointment");
menuItem5 = new JMenuItem("Show");
appMenu.add(menuItem5);
menuItem2 = new JMenuItem("Fix");
appMenu.add(menuItem2);
menuItem1 = new JMenuItem("Cancel");
appMenu.add(menuItem1);
mainMenuBar.add(appMenu);
setJMenuBar(mainMenuBar);
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
miViewDF.addActionListener(lSymAction);
miRegWithDF.addActionListener(lSymAction);
menuItem1.addActionListener(lSymAction);
menuItem2.addActionListener(lSymAction);
//listener di TextFieldAddress
textFieldDFaddress.addActionListener(lSymAction);
menuItem4.addActionListener(lSymAction);
menuItem3.addActionListener(lSymAction);
SymItem lSymItem = new SymItem();
//listNames.addItemListener(lSymItem);
listNames.addListSelectionListener(new NameListener());
menuItem5.addActionListener(lSymAction);
setLocation(50, 50);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -