From de167377c334164e8433c41a6e2ac9297ec29c80 Mon Sep 17 00:00:00 2001 From: mdb Date: Fri, 11 Jul 2003 03:42:27 +0000 Subject: [PATCH] Added two convenience methods for immediately dispatching actions on a controller. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1166 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/swing/Controller.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/swing/Controller.java b/projects/samskivert/src/java/com/samskivert/swing/Controller.java index 57de1b9a..7df55c04 100644 --- a/projects/samskivert/src/java/com/samskivert/swing/Controller.java +++ b/projects/samskivert/src/java/com/samskivert/swing/Controller.java @@ -1,5 +1,5 @@ // -// $Id: Controller.java,v 1.15 2002/06/19 23:22:40 mdb Exp $ +// $Id: Controller.java,v 1.16 2003/07/11 03:42:27 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -231,6 +231,30 @@ public abstract class Controller } } + /** + * A convenience method for constructing and immediately handling an + * event on this controller (via {@link #handleAction(ActionEvent)}). + * + * @return true if the controller knew how to handle the action, false + * otherwise. + */ + public boolean handleAction (Component source, String command) + { + return handleAction(new ActionEvent(source, 0, command)); + } + + /** + * A convenience method for constructing and immediately handling an + * event on this controller (via {@link #handleAction(ActionEvent)}). + * + * @return true if the controller knew how to handle the action, false + * otherwise. + */ + public boolean handleAction (Component source, String command, Object arg) + { + return handleAction(new CommandEvent(source, command, arg)); + } + /** * Used by {@link #handleAction} to generate arguments to the action * handler method.