Your Own Custom Java Console in Notes Client
When writing Java Agents that run in the Notes client you can use the Java Console to see the result of any System.out.println() calls. Useful for debugging and dumping stack traces to when there's an error.
To display the Java Console you need to look inside the Tools menu of the Notes client. Not something an average user would know to do and not something you could expect them to do.
The Java Console is therefore best used by us developers and isn't much use when it comes to displaying text to an actual user, which is what I needed to do this week and so I wrote a simple Java class to let me report back to the user, like so, as an Agent progresses.
The class is called OutputWindow (I've never been much good at naming things) and a sample usage looks like this:
public class JavaAgent extends AgentBase { private OutputWindow output; public void NotesMain() { try { output = new OutputWindow(); output.show(); output.println("About to run the code..."); for(int i=0; i<=100; i++ ){ output.println( Integer.toString( 1 / ( 20 - i ) ) ); } } catch(Exception e) { output.showErrorMessage("There was an error! See main window for more details"); output.append(Utils.getStackTraceAsString(e)); e.printStackTrace(); } finally { output.setCloseable(true); } } }
Notice that is has a "showErrorMessage" helper method which results in this:
If it's of use to you then the code is here. I'm not saying it's perfect code, but it does a job.
Useful to have a console meant for users and not only developers
Had same idea some years a go :-)
A Java and LotusScript console:
http://nevermind.dk/nevermind/blog... ..-have-an-output-console-for-java-and-lotusscript-agents.
PS In Swing you should always update the GUI in its own thread.
Reply
Great minds think alike ;-)
Reply
Jesper,
Your blog is awesome! I can't believe I've never seen or heard about it before today. I'm adding it to my RSS feeds.
Reply
Show the rest of this thread