1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| package com.ibm.NotesJava.agents;
import lotus.domino.AgentBase;
import lotus.domino.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
// first, let's get the system properties as a String
StringWriter sw = new StringWriter();
System.getProperties().list(new PrintWriter(sw));
// easy enough...now create a simple dialog to display the results
// (make the Dialog final so we can access it from the ActionListeners)
final Dialog msgbox = new Dialog(new Frame(), "System Properties", true);
msgbox.setLayout(new BorderLayout());
// create the label
msgbox.add("North", new Label("Here are the Java System Properties for this machine:"));
// create a text area
TextArea props = new TextArea(sw.toString(), 10, 50);
msgbox.add("Center", props);
// make a button so the user can close the dialog
Panel buttons = new Panel();
buttons.setLayout(new FlowLayout());
Button close = new Button("Close");
close.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
msgbox.dispose();
}
} );
buttons.add(close);
msgbox.add("South", buttons);
// display everything
Dimension d = msgbox.getToolkit().getScreenSize();
msgbox.setLocation(d.width/3, d.height/3); // center the MessageBox
msgbox.pack(); // organize all its components
msgbox.setResizable(false); // make sure the user can't resize it
msgbox.toFront(); // give the MessageBox focus
msgbox.show(); // and display it
} catch(Exception e) {
e.printStackTrace();
}
}
} |
Partager