@Override public void paintChildren(Graphics g) { super.paintChildren(g); if (exitAfterFirstPaint) { System.exit(0); } }
private void winning() { String[] options = {"Try again", "Go back to Start", "Quit"}; InformationFrame.stopClock(); int n = JOptionPane.showOptionDialog( rootPane, "You won!" + "\n╔══╗░░░░╔╦╗░░╔═════╗" + "\n║╚═╬════╬╣╠═╗║░▀░▀░║" + "\n╠═╗║╔╗╔╗║║║╩╣║╚═══╝║" + "\n╚══╩╝╚╝╚╩╩╩═╝╚═════╝", "Smileys c: ☺ ☻ ت ヅ ツ ッ シ Ü ϡ ﭢ" + "\nWhat would you like to do now?", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == 2) { // System.out.println("n = " + n); System.exit(0); } else if (n == 1) { InformationFrame.dispose(); main(null); this.dispose(); } else if (n == 0) { String difficulty = MainManager.getMainGrid().getDifficulty(); MainPanel.removeAll(); constructMinesweeper(difficulty.toLowerCase()); } }
/** constructor */ public DanceQueuePanel() { // flow layout setLayout(new FlowLayout()); // uses buffer to draw arrows based on queues in an array myImage = new BufferedImage(600, 600, BufferedImage.TYPE_INT_RGB); myBuffer = myImage.getGraphics(); // uses timer to queue buffer changes time = 0; timer = new Timer(5, new Listener()); timer.start(); setFocusable(true); // picks instructions based on song & level if (Danceoff.getSong() == -1 && Danceoff.getDifficulty() == 0) { arrows = new Arrow[] {new UpArrow(1000), new DownArrow(2000), new LeftArrow(3000)}; } // setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK, 3), // "DanceQueuePanel")); // load images for arrows rightArrowImg = null; leftArrowImg = null; upArrowImg = null; downArrowImg = null; try { rightArrowImg = ImageIO.read(new File("arrowB right.png")); leftArrowImg = ImageIO.read(new File("arrowB left.png")); upArrowImg = ImageIO.read(new File("arrowB up copy.png")); downArrowImg = ImageIO.read(new File("arrowB down.png")); } catch (IOException e) { warn("YOU FAIL", e); System.exit(2); } }
/** Prints an error message. */ private static void printError(String msg, boolean quit) { System.err.println(msg); if (quit) { System.err.println("See mucommander --help for more information."); System.exit(1); } }
/** * Restart of the application server : * * <p>All running services are stopped. LookupManager is flushed. * * <p>Client code that started us should notice the special return value and restart us. */ protected final void doExecute(AdminCommandContext context) { try { // unfortunately we can't rely on constructors with HK2... if (registry == null) throw new NullPointerException( new LocalStringsImpl(getClass()) .get("restart.server.internalError", "registry was not set")); init(context); if (!verbose) { // do it now while we still have the Logging service running... reincarnate(); } // else we just return a special int from System.exit() Collection<Module> modules = registry.getModules("com.sun.enterprise.osgi-adapter"); if (modules.size() == 1) { final Module mgmtAgentModule = modules.iterator().next(); mgmtAgentModule.stop(); } else context.getLogger().warning(strings.get("restart.server.badNumModules", modules.size())); } catch (Exception e) { context.getLogger().severe(strings.get("restart.server.failure", e)); } int ret = RESTART_NORMAL; if (debug != null) ret = debug ? RESTART_DEBUG_ON : RESTART_DEBUG_OFF; System.exit(ret); }
/** * startLogger initializes and returns a file at logLoc with the results of logging at level * logLevel. * * @param logLoc location of the output log file- a string * @param logLevel logging level (is parsed by level.parse()) * @return Logger object to log to. */ public Logger startLogger(String logLoc, String logLevel) { try { fh = new FileHandler(logLoc); // sets output log file at logLoc } catch (SecurityException e) { e.printStackTrace(); System.err.println("SecurityException establishing logger. Exiting...\n"); System.exit(1); } catch (IOException e) { e.printStackTrace(); System.err.println("IOException establishing logger. Exiting...\n"); System.exit(1); } fh.setFormatter(new SimpleFormatter()); // format of log is 'human-readable' simpleformat logger.addHandler(fh); // attach formatter to logger logger.setLevel(Level.parse(logLevel)); // set log level return logger; }
/** * Start the JobTracker process. This is used only for debugging. As a rule, JobTracker should be * run as part of the DFS Namenode process. */ public static void main(String argv[]) throws IOException, InterruptedException { if (argv.length != 0) { System.out.println("usage: JobTracker"); System.exit(-1); } startTracker(new Configuration()); }
public static void quit() { try { if (instance.onQuit()) { System.exit(0); } } catch (Exception e) { Logger().severe("Error when quiting: " + e.getMessage()); } }
// TODO add exception for invalid options private void loadCLO(String[] args) { Options options = new Options(); String[][] clolist = { // {"variable/optionname", "description"}, {"genConfig", "general configuration file location"}, {"inWeightsLoc", "input weights configuration file location"}, {"inDBLoc", "input database file location"}, {"outWeightsLoc", "output weights configuration file location"}, {"outDBLoc", "output database file location"}, {"p3pLocation", "adding to DB: single policy file location"}, {"p3pDirLocation", "adding to DB: multiple policy directory location"}, {"newDB", "create new database in place of old one (doesn't check for existence of old one"}, {"newPolicyLoc", "the policy object to process"}, {"userResponse", "response to specified policy"}, {"userIO", "user interface"}, {"userInit", "initialization via user interface"}, {"policyDB", "PolicyDatabase backend"}, {"cbrV", "CBR to use"}, {"blanketAccept", "automatically accept the user suggestion"}, {"loglevel", "level of things save to the log- see java logging details"}, {"policyDB", "PolicyDatabase backend"}, {"NetworkRType", "Network Resource type"}, {"NetworkROptions", "Network Resource options"}, {"confidenceLevel", "Confidence threshold for consulting a networked resource"}, {"useNet", "use networking options"}, {"loglocation", "where to save the log file"}, {"loglevel", "the java logging level to use. See online documentation for enums."} }; for (String[] i : clolist) { options.addOption(i[0], true, i[1]); } CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Error parsing commandline arguments."); e.printStackTrace(); System.exit(3); } /* for(String i : args) { System.err.println(i); } */ for (String[] i : clolist) { if (cmd.hasOption(i[0])) { System.err.println("found option i: " + i); genProps.setProperty(i[0], cmd.getOptionValue(i[0])); } } System.err.println(genProps); }
private static void validateArgs(String[] args) { if (args.length != 2) { System.err.println("Error: incorrect arguments specified!"); System.err.println(""); System.err.println("USAGE: java -jar volleyball.jar <gyms.csv> <teams.csv>"); System.err.println(""); System.exit(1); } }
/** Prints muCommander's version to stdout and exits. */ private static void printVersion() { System.out.println(RuntimeConstants.APP_STRING); System.out.print("Copyright (C) "); System.out.print(RuntimeConstants.COPYRIGHT); System.out.println(" Maxence Bernard"); System.out.println( "This is free software, distributed under the terms of the GNU General Public License."); System.exit(0); }
/** Prints muCommander's command line usage and exits. */ private static void printUsage() { System.out.println("Usage: mucommander [options] [folders]"); System.out.println("Options:"); // Allows users to tweak how file associations are loaded / saved. System.out.println(" -a FILE, --assoc FILE Load associations from FILE."); // Allows users to tweak how bookmarks are loaded / saved. System.out.println(" -b FILE, --bookmarks FILE Load bookmarks from FILE."); // Allows users to tweak how configuration is loaded / saved. System.out.println(" -c FILE, --configuration FILE Load configuration from FILE"); // Allows users to tweak how command bar configuration is loaded / saved. System.out.println(" -C FILE, --commandbar FILE Load command bar from FILE."); // Allows users to change the extensions folder. System.out.println(" -e FOLDER, --extensions FOLDER Load extensions from FOLDER."); // Allows users to tweak how custom commands are loaded / saved. System.out.println(" -f FILE, --commands FILE Load custom commands from FILE."); // Ignore warnings. System.out.println(" -i, --ignore-warnings Do not fail on warnings (default)."); // Allows users to tweak how keymaps are loaded. System.out.println(" -k FILE, --keymap FILE Load keymap from FILE"); // Allows users to change the preferences folder. System.out.println(" -p FOLDER, --preferences FOLDER Store configuration files in FOLDER"); // muCommander will not print verbose error messages. System.out.println(" -S, --silent Do not print verbose error messages"); // Allows users to tweak how shell history is loaded / saved. System.out.println(" -s FILE, --shell-history FILE Load shell history from FILE"); // Allows users to tweak how toolbar configuration are loaded. System.out.println(" -t FILE, --toolbar FILE Load toolbar from FILE"); // Allows users to tweak how credentials are loaded. System.out.println(" -u FILE, --credentials FILE Load credentials from FILE"); // Text commands. System.out.println(" -h, --help Print the help text and exit"); System.out.println(" -v, --version Print the version and exit"); // muCommander will print verbose boot error messages. System.out.println(" -V, --verbose Print verbose error messages (default)"); // Pedantic mode. System.out.println( " -w, --fail-on-warnings Quits when a warning is encountered during"); System.out.println(" the boot process."); System.exit(0); }
public UCFIndexerDriver(String configFile) { try { m_testData = ConfigLoader.loadDataFromConfigFile(configFile); setupLogging(); m_rootHost = m_testData.getRootHost(); m_rootPort = m_testData.getRootPort(); m_protocol = m_testData.getProtocol(); m_appl = m_testData.getAppl(); setTestURL(); } catch (ConfigException e) { System.err.println("Exception: " + e.getMessage()); e.printStackTrace(); System.exit(1); } catch (IOException ioe) { System.err.println("Exception: " + ioe.getMessage()); ioe.printStackTrace(); System.exit(2); } }
/** * writes a property file to disk * * @param wprops the property file to write * @param wloc where to write to */ private void writePropertyFile(Properties wprops, String wloc) { if (wprops == null) System.out.println("wrops null in gio/writepropertyfile"); if (wloc == null) System.out.println("wloc null in gio/writepropertyfile"); try { wprops.store(new FileOutputStream(wloc), null); } catch (IOException e) { System.err.println("Error writing weights to file."); e.printStackTrace(); System.exit(3); } }
/** * converts a string into a valid CBR * * @param string the string to parse * @return the CBR to use * @throws Exception */ private CBR parseCBR(String string) throws Exception { try { return (string == null) ? (null) : (new CBR(this)).parse(string); } catch (Exception e) { System.err.println("error parsing CBR, exiting."); e.printStackTrace(); System.exit(5); return null; } }
public static void main(String args[]) { try { UCFIndexerDriver test = new UCFIndexerDriver(args[0]); test.run(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); System.exit(1); } }
static { try { properties = new Properties(); properties.load(Notepad.class.getResourceAsStream("resources/NotepadSystem.properties")); resources = ResourceBundle.getBundle("resources.Notepad", Locale.getDefault()); } catch (MissingResourceException | IOException e) { System.err.println( "resources/Notepad.properties " + "or resources/NotepadSystem.properties not found"); System.exit(1); } }
// TODO add exception for invalid options public Properties loadFromConfig(String fileLoc) { Properties configFile = new Properties(); try { File localConfig = new File(fileLoc); InputStream is = null; if (localConfig.exists()) { is = new FileInputStream(localConfig); } else { System.err.println( "No configuration file at " + fileLoc + ". Please place one in the working directory."); System.exit(3); } configFile.load(is); } catch (IOException e) { e.printStackTrace(); System.err.println("IOException reading first configuration file. Exiting...\n"); System.exit(1); } return configFile; }
@Override protected void processWindowEvent(final WindowEvent e) { if (e.getID() == WindowEvent.WINDOW_CLOSING) { if (!plugin) { dispose(); System.exit(0); } else { saveWindowState(); setVisible(false); } } else { super.processWindowEvent(e); } }
/** * returns the policy object from the policyObject option * * @return the policy object to be processed */ public void loadPO() { if (genProps.getProperty("newPolicyLoc", null) == null) System.err.println("newPolLoc == null in gio:loadPO"); File pLoc = new File(genProps.getProperty("newPolicyLoc", null)); if (!pLoc.exists()) { System.err.println("no file found at p3p policy location specified by the new policy option"); System.exit(1); } po = (new P3PParser()).parse(pLoc.getAbsolutePath()); // TODO make sure that the context is parsed if avaliable if (po.getContext().getDomain() == null) { po.setContext( new Context( new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()), genProps.getProperty("newPolicyLoc"))); } }
/** * Open the aware-p webpage in the browser. * * @param url */ private void browse(String url) { if (!java.awt.Desktop.isDesktopSupported()) { System.err.println("Desktop is not supported"); return; } java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { System.err.println("Desktop doesn't support the browse action"); System.exit(1); } try { java.net.URI uri = new java.net.URI(url); desktop.browse(uri); } catch (Exception e) { System.err.println(e.getMessage()); } }
/** * Exit method. Exits the program as does Alt+F4 or Clicking the Red X in the upper right corner. * * @param evt User Mouse Click release. */ private void QuitButtonMouseReleased(MouseEvent evt) { // TODO add your handling code here: // this.dispose(); old way System.exit(0); }
/* Function to evaluate an expression recursively. */ public int evaluateExpression(String expr) { String expr1 = "", expr2 = "", var = ""; int value = 0, result = 0; logger.log(DEBUG, "Evaluating expression: " + expr); try { if (expr.matches("\\d+")) { /* The expression is a number */ result = Integer.parseInt(expr); } else if (expr.startsWith("add(")) { /* Addition */ if (!expr.endsWith(")")) { throw new IllegalArgumentException("Expression " + expr + " does not end with )!"); } expr1 = extractOperand(expr.substring(4)); expr2 = expr.substring(expr1.length() + 5, expr.length() - 1); logger.log(DEBUG, "First operand: " + expr1); logger.log(DEBUG, "Second operand: " + expr2); result = evaluateExpression(expr1) + evaluateExpression(expr2); } else if (expr.startsWith("sub(")) { /* Subtraction */ if (!expr.endsWith(")")) { throw new IllegalArgumentException("Expression " + expr + " does not end with )!"); } expr1 = extractOperand(expr.substring(4)); expr2 = expr.substring(expr1.length() + 5, expr.length() - 1); logger.log(DEBUG, "First operand: " + expr1); logger.log(DEBUG, "Second operand: " + expr2); result = evaluateExpression(expr1) - evaluateExpression(expr2); } else if (expr.startsWith("mult(")) { /* Multiplication */ if (!expr.endsWith(")")) { throw new IllegalArgumentException("Expression " + expr + " does not end with )!"); } expr1 = extractOperand(expr.substring(5)); expr2 = expr.substring(expr1.length() + 6, expr.length() - 1); logger.log(DEBUG, "First operand: " + expr1); logger.log(DEBUG, "Second operand: " + expr2); result = evaluateExpression(expr1) * evaluateExpression(expr2); } else if (expr.startsWith("div(")) { /* Division */ if (!expr.endsWith(")")) { throw new IllegalArgumentException("Expression " + expr + " does not end with )!"); } expr1 = extractOperand(expr.substring(4)); expr2 = expr.substring(expr1.length() + 5, expr.length() - 1); logger.log(DEBUG, "First operand: " + expr1); logger.log(DEBUG, "Second operand: " + expr2); int divisor = evaluateExpression(expr2); if (divisor == 0) { throw new ArithmeticException("Division by 0 error!"); } result = evaluateExpression(expr1) / divisor; } else if (expr.startsWith("let(")) { /* Let operation */ if (!expr.endsWith(")")) { throw new IllegalArgumentException("Expression " + expr + " does not end with )!"); } var = extractOperand(expr.substring(4)); if (vars.containsKey(var)) { /* Variable already declared */ throw new IllegalArgumentException("Variable \"" + var + "\" already declared!"); } expr1 = extractOperand(expr.substring(var.length() + 5)); value = evaluateExpression(expr1); vars.put(var, value); result = evaluateExpression( expr.substring(var.length() + expr1.length() + 6, expr.length() - 1)); logger.log(DEBUG, "Added variable " + var + " with value " + value); logger.log(DEBUG, "First operand: " + expr1); logger.log(DEBUG, "Second operand: " + result); } else if (expr.matches("[a-zA-Z]+")) { /* Expression is alphabetic. Check if it's a valid variable */ if (!vars.containsKey(expr)) { /* Undeclared variable */ throw new IllegalArgumentException("Undeclared variable \"" + expr + "\"!"); } return vars.get(expr); } else { throw new IllegalArgumentException( "Invalid expression \"" + expr + "\"! Must be one of add/sub/mult/div/let or a number or variable!"); } /* Remove the variable now that we're done with it and it can be reused in subsequent let statements. */ vars.remove(var); logger.log(DEBUG, "Removed variable " + var); } catch (Exception e) { logger.log(ERROR, e.toString()); System.exit(0); } logger.log(DEBUG, "Returned result is " + result); return result; }
protected Util(String[] args) { CommandLineParser cmdLineParse = new PosixParser(); Options options = new Options(); options.addOption("h", "help", false, "show this help message and exit"); options.addOption( OptionBuilder.withLongOpt("host") .withDescription("host to connect to (default 0.0.0.0)") .hasArg(true) .withArgName("HOST") .create('H')); options.addOption( OptionBuilder.withLongOpt("username") .withDescription("username to use for authentication") .hasArg(true) .withArgName("USERNAME") .create('u')); options.addOption( OptionBuilder.withLongOpt("password") .withDescription("password to use for authentication") .hasArg(true) .withArgName("PASSWORD") .create('w')); options.addOption( OptionBuilder.withLongOpt("port") .withDescription("port to connect to (default 5672)") .hasArg(true) .withArgName("PORT") .create('p')); options.addOption( OptionBuilder.withLongOpt("frame-size") .withDescription("specify the maximum frame size") .hasArg(true) .withArgName("FRAME_SIZE") .create('f')); options.addOption( OptionBuilder.withLongOpt("container-name") .withDescription("Container name") .hasArg(true) .withArgName("CONTAINER_NAME") .create('C')); options.addOption(OptionBuilder.withLongOpt("ssl").withDescription("Use SSL").create('S')); options.addOption( OptionBuilder.withLongOpt("remote-hostname") .withDescription("hostname to supply in the open frame") .hasArg(true) .withArgName("HOST") .create('O')); if (hasBlockOption()) options.addOption( OptionBuilder.withLongOpt("block") .withDescription("block until messages arrive") .create('b')); if (hasCountOption()) options.addOption( OptionBuilder.withLongOpt("count") .withDescription("number of messages to send (default 1)") .hasArg(true) .withArgName("COUNT") .create('c')); if (hasModeOption()) options.addOption( OptionBuilder.withLongOpt("acknowledge-mode") .withDescription( "acknowledgement mode: AMO|ALO|EO (At Least Once, At Most Once, Exactly Once") .hasArg(true) .withArgName("MODE") .create('k')); if (hasSubjectOption()) options.addOption( OptionBuilder.withLongOpt("subject") .withDescription("subject message property") .hasArg(true) .withArgName("SUBJECT") .create('s')); if (hasSingleLinkPerConnectionMode()) options.addOption( OptionBuilder.withLongOpt("single-link-per-connection") .withDescription( "acknowledgement mode: AMO|ALO|EO (At Least Once, At Most Once, Exactly Once") .hasArg(false) .create('Z')); if (hasFilterOption()) options.addOption( OptionBuilder.withLongOpt("filter") .withDescription("filter, e.g. exact-subject=hello; matching-subject=%.a.#") .hasArg(true) .withArgName("<TYPE>=<VALUE>") .create('F')); if (hasTxnOption()) { options.addOption("x", "txn", false, "use transactions"); options.addOption( OptionBuilder.withLongOpt("batch-size") .withDescription("transaction batch size (default: 1)") .hasArg(true) .withArgName("BATCH-SIZE") .create('B')); options.addOption( OptionBuilder.withLongOpt("rollback-ratio") .withDescription("rollback ratio - must be between 0 and 1 (default: 0)") .hasArg(true) .withArgName("RATIO") .create('R')); } if (hasLinkDurableOption()) { options.addOption("d", "durable-link", false, "use a durable link"); } if (hasStdInOption()) options.addOption("i", "stdin", false, "read messages from stdin (one message per line)"); options.addOption( OptionBuilder.withLongOpt("trace") .withDescription("trace logging specified categories: RAW, FRM") .hasArg(true) .withArgName("TRACE") .create('t')); if (hasSizeOption()) options.addOption( OptionBuilder.withLongOpt("message-size") .withDescription("size to pad outgoing messages to") .hasArg(true) .withArgName("SIZE") .create('z')); if (hasResponseQueueOption()) options.addOption( OptionBuilder.withLongOpt("response-queue") .withDescription("response queue to reply to") .hasArg(true) .withArgName("RESPONSE_QUEUE") .create('r')); if (hasLinkNameOption()) { options.addOption( OptionBuilder.withLongOpt("link") .withDescription("link name") .hasArg(true) .withArgName("LINK") .create('l')); } if (hasWindowSizeOption()) { options.addOption( OptionBuilder.withLongOpt("window-size") .withDescription("credit window size") .hasArg(true) .withArgName("WINDOW-SIZE") .create('W')); } CommandLine cmdLine = null; try { cmdLine = cmdLineParse.parse(options, args); } catch (ParseException e) { printUsage(options); System.exit(-1); } if (cmdLine.hasOption('h') || cmdLine.getArgList().isEmpty()) { printUsage(options); System.exit(0); } _host = cmdLine.getOptionValue('H', "0.0.0.0"); _remoteHost = cmdLine.getOptionValue('O', null); String portStr = cmdLine.getOptionValue('p', "5672"); String countStr = cmdLine.getOptionValue('c', "1"); _useSSL = cmdLine.hasOption('S'); if (hasWindowSizeOption()) { String windowSizeStr = cmdLine.getOptionValue('W', "100"); _windowSize = Integer.parseInt(windowSizeStr); } if (hasSubjectOption()) { _subject = cmdLine.getOptionValue('s'); } if (cmdLine.hasOption('u')) { _username = cmdLine.getOptionValue('u'); } if (cmdLine.hasOption('w')) { _password = cmdLine.getOptionValue('w'); } if (cmdLine.hasOption('F')) { _filter = cmdLine.getOptionValue('F'); } _port = Integer.parseInt(portStr); _containerName = cmdLine.getOptionValue('C'); if (hasBlockOption()) _block = cmdLine.hasOption('b'); if (hasLinkNameOption()) _linkName = cmdLine.getOptionValue('l'); if (hasLinkDurableOption()) _durableLink = cmdLine.hasOption('d'); if (hasCountOption()) _count = Integer.parseInt(countStr); if (hasStdInOption()) _useStdIn = cmdLine.hasOption('i'); if (hasSingleLinkPerConnectionMode()) _useMultipleConnections = cmdLine.hasOption('Z'); if (hasTxnOption()) { _useTran = cmdLine.hasOption('x'); _batchSize = Integer.parseInt(cmdLine.getOptionValue('B', "1")); _rollbackRatio = Double.parseDouble(cmdLine.getOptionValue('R', "0")); } if (hasModeOption()) { _mode = AcknowledgeMode.ALO; if (cmdLine.hasOption('k')) { _mode = AcknowledgeMode.valueOf(cmdLine.getOptionValue('k')); } } if (hasResponseQueueOption()) { _responseQueue = cmdLine.getOptionValue('r'); } _frameSize = Integer.parseInt(cmdLine.getOptionValue('f', "65536")); if (hasSizeOption()) { _messageSize = Integer.parseInt(cmdLine.getOptionValue('z', "-1")); } String categoriesList = cmdLine.getOptionValue('t'); String[] categories = categoriesList == null ? new String[0] : categoriesList.split("[, ]"); for (String cat : categories) { if (cat.equalsIgnoreCase("FRM")) { FRAME_LOGGER.setLevel(Level.FINE); Formatter formatter = new Formatter() { @Override public String format(final LogRecord record) { return "[" + record.getMillis() + " FRM]\t" + record.getMessage() + "\n"; } }; for (Handler handler : FRAME_LOGGER.getHandlers()) { FRAME_LOGGER.removeHandler(handler); } Handler handler = new ConsoleHandler(); handler.setLevel(Level.FINE); handler.setFormatter(formatter); FRAME_LOGGER.addHandler(handler); } else if (cat.equalsIgnoreCase("RAW")) { RAW_LOGGER.setLevel(Level.FINE); Formatter formatter = new Formatter() { @Override public String format(final LogRecord record) { return "[" + record.getMillis() + " RAW]\t" + record.getMessage() + "\n"; } }; for (Handler handler : RAW_LOGGER.getHandlers()) { RAW_LOGGER.removeHandler(handler); } Handler handler = new ConsoleHandler(); handler.setLevel(Level.FINE); handler.setFormatter(formatter); RAW_LOGGER.addHandler(handler); } } _args = cmdLine.getArgs(); }
public void actionPerformed(ActionEvent e) { System.exit(0); }
@Override public void windowClosing(WindowEvent e) { System.exit(0); }
public static void main(String[] args) { // Check if user supplied a filename if (args.length < 1) { System.err.println("USAGE: java VslComp <fichier.vsl>"); System.exit(1); } // Setting up the logger (mainly for debugging purposes) Handler h = new ConsoleHandler(); Util.log.addHandler(h); Util.log.fine("Logger initialized"); // Optional debug argument if (args.length > 1 && args[1].equals("-debug")) { h.setLevel(Level.FINE); Util.log.setLevel(Level.FINE); Util.log.log(Level.FINE, "DEBUG on"); } // We encapsulate the code in a generic try block in order to catch any // exception that may be raised. try { // Util.vslFilename contains the name of the file being compiled, to // emulate gcc's style of error messages. Util.vslFilename = args[0]; // We give the file as input for ANTLR, which produces a character // stream. ANTLRFileStream input = new ANTLRFileStream(args[0]); // Then, we run the lexer... VSLLexer lexer = new VSLLexer(input); // To obtain a token stream. CommonTokenStream token_stream = new CommonTokenStream(lexer); // This token stream is fed to the parser (which will not yet start // the parsing). VSLParser parser = new VSLParser(token_stream); // Here, we start parsing with the main rule of the grammar, 's'. // <<< NOTE: this line must be changed during development, if one // wishes to parse just a fragment of the language (e.g. begin with // an expression). >>> VSLParser.s_return r = parser.s(); // VSLParser.function_return r = parser.function(); // The parser produces an AST. CommonTree t = (CommonTree) r.getTree(); // System.out.println("--PARSER--\n"); // printTree(t,0); // If debugging is on, this prints the resulting tree in LISP // notation Util.log.fine(t.toStringTree()); // From the AST, we create a node stream. CommonTreeNodeStream nodes = new CommonTreeNodeStream(t); // nodes.setTreeAdaptor(astAdaptor); // This node stream is fed to the tree parser. VSLTreeParser tparser = new VSLTreeParser(nodes); try { // The tree parser starts in the rule defined by the next line. // <<< NOTE: this line must be changed during development, if // one wishes to parse just a fragment of the language (e.g. // begin with an expression). >>> // Code3a code = tparser.s(new SymbolTable()); Code3a code = tparser.program(new SymbolTable()); // Code3a code = tparser.code(); // CommonTree tparsertree = (CommonTree) tparser.s().getTree(); // CommonTree tparsertree = (CommonTree) tparser.function().getTree(); // System.out.println("--TREEPARSER--\n"); // printTree(tparsertree,0); // System.out.println(tparser.s().replaceAll("null", "")); // Code3a code = new Code3a(); // code.print(); // System.out.println("================== MIPS Code"); // We prepare the MIPS code generator, which will compile // the three-address code into MIPS assembly. MIPSCodeGenerator cg = new MIPSCodeGenerator(System.out); // NOT NEEDED AT THE BEGINNING // NOTE: if necessary, uncomment the call to addStubMain // to add the header and footer for the main function. // This allows the program to be run using the NachOS // emulator. // code = cg.addStubMain(code); // NOT NEEDED AT THE BEGINNING // Generates the actual MIPS code, printing it to the // stream chosen previously (by default, System.out). cg.genCode(code); // NOT NEEDED AT THE BEGINNING // The rest of the main function are standard error handlers. } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); } } catch (FileNotFoundException fnf) { System.err.println("exception: " + fnf); } catch (RecognitionException re) { // This usually indicates the program is syntactically incorrect. System.err.println("Recognition exception: " + re); } catch (IOException exc) { System.out.println("IO exception"); } }
/** * Losing Function. This method contains everything required to end a game, and also give the user * options afterwards. */ private void losing() { InformationFrame.stopClock(); timerStart = false; for (int r = 0; r < ButtonGrid.length; r++) { for (int c = 0; c < ButtonGrid[1].length; c++) { if (MainManager.getMainGrid().getMines(r, c) == 9) { ButtonGrid[r][c].setSelected(true); // prepare special icons ImageIcon MineIcon; MineIcon = new ImageIcon( "C://Users/Joseph/Downloads/GitHub/" + "Outside/2013/Minesweeper/src/Images/MineImage.png"); // prepare resize Image MineImage = MineIcon.getImage(); // transform it int maxSize = Math.max(ButtonGrid[r][c].getHeight(), ButtonGrid[r][c].getWidth()) / 2; Image rescaledImage; ImageIcon imageIcon; rescaledImage = MineImage.getScaledInstance( maxSize, maxSize, Image.SCALE_SMOOTH); // scale it the smooth way imageIcon = new ImageIcon(rescaledImage); // transform it back JLabel test1 = new JLabel(imageIcon); ButtonGrid[r][c].add(test1); // ButtonGrid[r][c].repaint(); resetFont("", r, c); } } } /* JOptionPane.showMessageDialog(rootPane, "You lose. Sorry." + "\n╔╦╦╦╦╦╦╦╦╦╦╦╦╗" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬█╬╬╬╬╬╬█╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬██████████╬╣" + "\n╠╬█╬╬╬╬╬╬╬╬█╬╣" + "\n╚╩╩╩╩╩╩╩╩╩╩╩╩╝", "☹", JOptionPane.YES_NO_CANCEL_OPTION); * */ // Custom button text String[] options = {"Try again", "Go back to Start", "Quit"}; int n = JOptionPane.showOptionDialog( rootPane, "You lose. Sorry." + "\n╔╦╦╦╦╦╦╦╦╦╦╦╦╗" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬█╬╬╬╬╬╬█╬╬╣" + "\n╠╬╬╬╬╬╬█╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬██████████╬╣" + "\n╠╬█╬╬╬╬╬╬╬╬█╬╣" + "\n╚╩╩╩╩╩╩╩╩╩╩╩╩╝" + "\n What would you like to do?", "☹", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == 2) { // System.out.println("n = " + n); System.exit(0); } else if (n == 1) { InformationFrame.dispose(); main(null); this.dispose(); } else if (n == 0) { String difficulty = MainManager.getMainGrid().getDifficulty(); MainPanel.removeAll(); constructMinesweeper(difficulty.toLowerCase()); } for (int y = 0; y < ButtonGrid.length; y++) { for (int x = 0; x < ButtonGrid[1].length; x++) { ButtonGrid[y][x].setFocusable(false); } } System.out.println("You lose"); }
/** loads [additional] policies from commandline (either -p or -f) */ private void loadCLPolicies() { // we already checked to make sure we have one of the options avaliable File pLoc = null; PolicyObject p = null; if (genProps.getProperty("p3pLocation", null) != null) { pLoc = new File(genProps.getProperty("p3pLocation")); if (!pLoc.exists()) { System.err.println( "no file found at p3p policy location specified by the -p3p option: " + genProps.getProperty("p3pLocation")); System.err.println("current location is " + System.getProperty("user.dir")); System.exit(1); } try { p = (new P3PParser()).parse(pLoc.getAbsolutePath()); if (p.getContextDomain() == null) { p.setContext( new Context( new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()), genProps.getProperty("p3pLocation"))); } pdb.addPolicy(p); } catch (Exception e) { System.err.println("Error with parsing or database"); e.printStackTrace(); // System.exit(5); } } if (genProps.getProperty("p3pDirLocation", null) != null) { pLoc = new File(genProps.getProperty("p3pDirLocation")); File[] pfiles = pLoc.listFiles(); // System.err.println("pfiles for p3pDirLocation: "+pfiles); for (int i = 0; i < pfiles.length; i++) { pLoc = (pfiles[i]); if (!pLoc.exists()) { System.err.println( "no file found at p3p policy location specified by the -p3pDirLocation option, " + genProps.getProperty("p3pDirLocation")); System.exit(1); } try { p = (new P3PParser()).parse(pLoc.getAbsolutePath()); if (p.getContext().getDomain() == null) { p.setContext( new Context( new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()), pfiles[i].getAbsolutePath())); } pdb.addPolicy(p); } catch (Exception e) { System.err.println("Einar needs to fix this parsing error."); e.printStackTrace(); } } } }
private void ExitBtnMouseClicked( java.awt.event.MouseEvent evt) { // GEN-FIRST:event_ExitBtnMouseClicked // TODO add your handling code here: System.exit(0); } // GEN-LAST:event_ExitBtnMouseClicked