[Japi-cvs] SF.net SVN: japi:[1056] tools/keystrokes/trunk
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2009-02-22 12:01:13
|
Revision: 1056 http://japi.svn.sourceforge.net/japi/?rev=1056&view=rev Author: christianhujer Date: 2009-02-22 11:30:54 +0000 (Sun, 22 Feb 2009) Log Message: ----------- Make keystrokes use japi-lib-argparser. Modified Paths: -------------- tools/keystrokes/trunk/build.xml tools/keystrokes/trunk/keystrokes.iml tools/keystrokes/trunk/src/prj/net/sf/japi/tools/keystrokes/KeyStrokes.java Modified: tools/keystrokes/trunk/build.xml =================================================================== --- tools/keystrokes/trunk/build.xml 2009-02-22 11:28:57 UTC (rev 1055) +++ tools/keystrokes/trunk/build.xml 2009-02-22 11:30:54 UTC (rev 1056) @@ -23,6 +23,7 @@ &commonBuild; <target name="getlibs"> + <get src="http://downloads.sourceforge.net/japi/japi-lib-argparser-0.3.0.jar" dest="lib/japi-lib-argparser.jar" /> <get src="http://downloads.sourceforge.net/japi/japi-lib-swing-action-0.1.0.jar" dest="lib/japi-lib-swing-action.jar" /> </target> Modified: tools/keystrokes/trunk/keystrokes.iml =================================================================== --- tools/keystrokes/trunk/keystrokes.iml 2009-02-22 11:28:57 UTC (rev 1055) +++ tools/keystrokes/trunk/keystrokes.iml 2009-02-22 11:30:54 UTC (rev 1056) @@ -28,6 +28,7 @@ </library> </orderEntry> <orderEntry type="module" module-name="libs-swing-action" /> + <orderEntry type="module" module-name="libs-argparser" /> </component> <component name="copyright"> <Base> Modified: tools/keystrokes/trunk/src/prj/net/sf/japi/tools/keystrokes/KeyStrokes.java =================================================================== --- tools/keystrokes/trunk/src/prj/net/sf/japi/tools/keystrokes/KeyStrokes.java 2009-02-22 11:28:57 UTC (rev 1055) +++ tools/keystrokes/trunk/src/prj/net/sf/japi/tools/keystrokes/KeyStrokes.java 2009-02-22 11:30:54 UTC (rev 1056) @@ -30,6 +30,7 @@ import static java.text.DateFormat.getTimeInstance; import static java.util.Arrays.asList; import java.util.Date; +import java.util.List; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; @@ -39,6 +40,8 @@ import javax.swing.KeyStroke; import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; import javax.swing.text.JTextComponent; +import net.sf.japi.io.args.ArgParser; +import net.sf.japi.io.args.BasicCommand; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -48,7 +51,7 @@ /** A small tool that displays the keystrokes while typing. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class KeyStrokes implements InputMethodListener, KeyListener { +public class KeyStrokes extends BasicCommand implements InputMethodListener, KeyListener { /** Action Builder. */ private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.japi.tools.keystrokes"); @@ -76,24 +79,9 @@ * @param args command line arguments */ public static void main(@NotNull final String... args) { - //noinspection ResultOfObjectAllocationIgnored - new KeyStrokes(); + ArgParser.simpleParseAndRun(new KeyStrokes(), args); } - /** Create a KeyStrokes tool. */ - public KeyStrokes() { - final JFrame frame = new JFrame(ACTION_BUILDER.getString("frame.title")); - //noinspection ThisEscapedInObjectConstruction - frame.addKeyListener(this); - //noinspection ThisEscapedInObjectConstruction - frame.addInputMethodListener(this); - frame.enableInputMethods(true); - frame.add(createContentPane()); - frame.pack(); - frame.setVisible(true); - frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); - } - /** Creates the content pane. * @return The newly created content pane. */ @@ -187,4 +175,19 @@ System.err.println(event); } + /** {@inheritDoc} */ + public int run(@NotNull final List<String> args) throws Exception { + final JFrame frame = new JFrame(ACTION_BUILDER.getString("frame.title")); + //noinspection ThisEscapedInObjectConstruction + frame.addKeyListener(this); + //noinspection ThisEscapedInObjectConstruction + frame.addInputMethodListener(this); + frame.enableInputMethods(true); + frame.add(createContentPane()); + frame.pack(); + frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + frame.setVisible(true); + return 0; + } + } // class KeyStrokes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |