sizeX
and sizeY
arguments to set the width and height of the application window), but we will also add arguments to be able to open an image file at the start of the application.
open
argument will specify that we want to open a fileimage
argument will specify the path of the file<arguments> <argument key="open" type="empty" /> <argument key="image" type="url" /> <argumentGroup key="open"> <argument key="open" mandatory="true" /> <argument key="image" mandatory="true" /> </argumentGroup> </arguments>
public class OpenImagePlugin extends AbstractMDIPlugin { @Override public URL getCommandLineConfiguration() { return this.getClass().getResource("commandline.xml"); } }We now will use the arguments in the Plugin:
public class OpenImagePlugin extends AbstractMDIPlugin { @Override public void handleCommandLineArguments(Map<String, ArgumentGroup> argumentGroups, Map<String, Argument> arguments) { if (argumentGroups.containsKey("open")) { ArgumentGroup group = argumentGroups.get("open"); File file = (File) group.getArgument("image").getValue(); try { importImage(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
sizeX
and sizeY
arguments, such as: Or we can use the sizeX
and sizeY
arguments, such as:
java -jar CommandlineTutorial2MDI.jar -sizeX=500 -sizeY=500
But now we can also start the application and open an image file, such with:
java -jar CommandlineTutorial2MDI.jar -open -image=myImage.jpg
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences