April 03, 2008

MessageBox and InputBox easily in a Notes Java agent

When you start to code Java as a notes developer you will very quickly start missing the msgbox and dialog boxes for simple interaction with the users. I did and started to develop my own MessageBox class which certainly could be better. Well, if you go through the Java API and look at the swing classes there are message boxes ready to use - Just what I was looking for.

Use this row to display information to the user:
JOptionPane.showMessageDialog(null, "Test");

Use this row to get information from the user:
String s = JOptionPane.showInputDialog("Get me some input dude!");

Add this code into a new Notes Java agent and run it from the Notes client:
import lotus.domino.*;
import javax.swing.JOptionPane;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();

/* Display message to user - like Notes MsgBox or MessageBox */
JOptionPane.showMessageDialog(null, "Test");

/* Display message to user and get user input - like Notes InputBox */
String s = JOptionPane.showInputDialog("Get me some input dude!");

/* Display the input */
JOptionPane.showMessageDialog(null, s);

} catch(Exception e) {

Technorati tags:
, , , , ,