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!");

Example:
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) {
e.printStackTrace();
}
}
}




Technorati tags:
, , , , ,


6 comments:

Anonymous said...

the above code dosenot work on web?????any solution

Anonymous said...

[script]
a = prompt("Hi!", "What's your name?");
[/script]

Anonymous said...

Thanks for the great tips

Unknown said...

Hi - I can get this to work, but when I click on the input box to add some text my Notes client screen goes white and Notes is very slow to respond. When I use my task manager I see a jvm running. If I go to this I can then see the dialog and respond accordingly. How do I overcome this problem? Thanks in advance, Fergus

Anonymous said...

Thank you Nick :)

Infosec Train said...

Nice post ! If you want to training for this course pls visit us - www.infosectrain.com