sizeX
and sizeY
Command-line arguments to set the width and height of the application window.
sizeX
and sizeY
arguments:<arguments> <argument key="sizeX" type="int" /> <argument key="sizeY" type="int" /> </arguments>
public class CommandlineTutorialMDI extends AbstractMDIApplication { @Override public URL getCommandLineConfiguration() { return this.getClass().getResource("commandline.xml"); } }We now will use the arguments in the application:
public class CommandlineTutorialMDI extends AbstractMDIApplication { private int sizeX = 200; private int sizeY = 200; public CommandlineTutorialMDI(String[] args) { super("Arguments SimpleExample"); super.preparePanels(); this.setCommandLineArguments(args); super.applyCommandLineArguments(); } @Override public URL getCommandLineConfiguration() { return this.getClass().getResource("commandline.xml"); } public static void main(String[] args) { CommandlineTutorialMDI mdi = new CommandlineTutorialMDI(args); mdi.setVisible(true); } }The last thing we must do is apply the arguments to set the width and height of the application window:
public CommandlineTutorialMDI(String[] args) { super("Arguments SimpleExample"); super.preparePanels(); this.setCommandLineArguments(args); super.applyCommandLineArguments(); this.setSize(sizeX, sizeY); } @Override public void handleCommandLineArguments(Map<String, ArgumentGroup> argumentGroups, Map<String, Argument> arguments) { if (arguments.containsKey("sizeX")) { Argument arg = arguments.get("sizeX"); sizeX = (Integer) arg.getValue(); } if (arguments.containsKey("sizeY")) { Argument arg = arguments.get("sizeY"); sizeY = (Integer) arg.getValue(); } }
java -jar CommandlineTutorialMDI.jar
Or we can use the sizeX
and sizeY
arguments, such as:
java -jar CommandlineTutorialMDI.jar -sizeX=500 -sizeY=500
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences