Exemple #1
1
  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());
    }
  }
    public void Dragon() {
      String message =
          "You have come face to face with Darth Vader."; // "You have awoken the sleeping dragon!
      // What will you do?";
      String title = "DARTH VADER!!!"; // "DRAGON!!!";

      usesword = "Use Light Saber"; // "Use Magic Sword";
      usedagger = "Use Glowing Hulk Mask";
      runaway = "Retreat!";
      final JButton retreat = new JButton(runaway);
      retreat.setCursor(new Cursor(Cursor.HAND_CURSOR));
      retreat.addActionListener(this);
      final JButton dagger = new JButton(usedagger);
      dagger.setCursor(new Cursor(Cursor.HAND_CURSOR));
      dagger.addActionListener(this);
      final JButton kill = new JButton(usesword);
      kill.setCursor(new Cursor(Cursor.HAND_CURSOR));
      kill.addActionListener(this);

      Object[] options = {kill, dagger, retreat};
      dragon.showOptionDialog(
          dragon,
          message,
          title,
          JOptionPane.YES_NO_CANCEL_OPTION,
          JOptionPane.QUESTION_MESSAGE,
          (new ImageIcon("MapPics/Vader.png")),
          options,
          options[2]);
    }
Exemple #3
0
 public void nameFocusLost(java.awt.event.FocusEvent evt) {
   ctxt.saveState = true;
   String newName = name.getText(), msg;
   while (!Library.validateFileName(newName, false)) {
     msg = "The name '" + newName + "' violates the rules for names:";
     msg += "\nIt must have 2 to 28 characters.";
     msg += "\nYou may not use BackSlash, ForwardSlash, Colon, DoubleQuote";
     msg += "\nAsterisk, QuestionMark, LeftAngleBracket, RightAngleBracket,";
     msg += "\nor the VerticalBar in a name. TRY AGAIN.";
     newName = JOptionPane.showInputDialog(msg);
   } //  end of harrass-em-until-they-give-a-good-name
   name.setText(newName);
   if (!newName.equals(ctxt.languageName)) { // Made a change
     msg = "Change this context's language name\nto" + newName + "?";
     String[] options = {newName, ctxt.languageName};
     int choice =
         JOptionPane.showOptionDialog(
             this,
             msg,
             "Confirm Changed Language Name",
             JOptionPane.YES_NO_OPTION,
             JOptionPane.QUESTION_MESSAGE,
             null,
             options,
             options[0]);
     if (choice == 0) { //  Change is confirmed
       ctxt.languageName = newName;
       msg =
           "Normally, the file name for a context is the same as the language name "
               + "\nfor that context.  Change this context's file name\n"
               + "to "
               + newName
               + "?";
       options[0] = "Change File Name";
       options[1] = "Do Not Change";
       choice =
           JOptionPane.showOptionDialog(
               this,
               msg,
               "Confirm Correct File Name",
               JOptionPane.YES_NO_OPTION,
               JOptionPane.QUESTION_MESSAGE,
               null,
               options,
               options[0]);
       if (choice == 0) {
         Library.userContextName = newName;
         if (SIL_Edit.edWin != null && ctxt == Library.contextUnderConstruction) {
           SIL_Edit.edWin.chart.changeFileName(newName);
         }
       }
     } //  end of Change-is-confirmed
   } //  end of change-was-made
 }
Exemple #4
0
 public void actionPerformed(ActionEvent e) {
   JFileChooser chooser = new JFileChooser();
   chooser.setDialogTitle("Load");
   int choice = 0;
   do {
     int result = chooser.showOpenDialog(null);
     if (result == JFileChooser.APPROVE_OPTION) {
       file = chooser.getSelectedFile();
       try {
         if (file != null) {
           fileName = file.getCanonicalPath();
           reader = new BufferedReader(new FileReader(fileName));
           String line;
           while ((line = reader.readLine()) != null) {
             myPatternList.add(line);
           }
           //							for(int i=0;i<myPatternList.size();i++) {
           //								responseArea.append(myPatternList.get(i)+"\n");
           //							}
         }
         choice = 2;
         reader.close();
       } catch (IOException c) {
         c.printStackTrace();
         Object[] options = new String[] {"Load New File", "Exit"};
         choice =
             JOptionPane.showOptionDialog(
                 null,
                 "Invalid FileChoosen." + "Would you like to load a new file " + "or exit?",
                 "Options",
                 JOptionPane.YES_NO_OPTION,
                 JOptionPane.ERROR_MESSAGE,
                 null,
                 options,
                 options[0]);
         if (choice == 1) System.exit(0);
       }
     } else if (result == JFileChooser.CANCEL_OPTION) {
       Object[] options = new String[] {"Load Different File", "Exit"};
       choice =
           JOptionPane.showOptionDialog(
               null,
               "Would you like to load a new file " + " or exit?",
               "Options",
               JOptionPane.YES_NO_OPTION,
               JOptionPane.ERROR_MESSAGE,
               null,
               options,
               options[0]);
       if (choice == 1) System.exit(0);
     }
   } while (choice == 0);
 }
  /**
   * Sla het spelbord op
   *
   * @param name
   */
  private void saveGameboard() {
    try {
      for (int row = 0; row < this.items.length; row++) {
        for (int cell = 0; cell < this.items[row].length; cell++) {
          DC.voerVakIn(String.format("%d,%d", row, cell), this.items[row][cell]);
        }
      }

      Object[] options = {lang.get("yes"), lang.get("no"), lang.get("cancel")};
      int keuze =
          JOptionPane.showOptionDialog(
              null,
              lang.get("game.board.save"),
              "Spelbord opslaan",
              JOptionPane.YES_NO_CANCEL_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              options,
              options[0]);

      if (keuze == 1) {
        // Men wil de wijzigingen verwerpen
        Object[] options2 = {lang.get("yes"), lang.get("no")};
        keuze =
            JOptionPane.showOptionDialog(
                null,
                lang.get("game.board.cancel"),
                "Ongedaanmaken spelbord",
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null,
                options2,
                options2[0]);

        if (keuze == 0) {
          DC.resetSpelbord();
          setError(lang.get("game.board.cancelled"));
        }
      } else if (keuze == 0) {
        DC.controleerSpelbord();
        DC.slaHuidigSpelbordOp();
        setError(lang.get("game.board.saved"));
      }

      this.items = DC.toonSpelbord();
      drawBoard();

    } catch (SpelException | SpelbordException e) {
      setError(e.getMessage());
    }
  }
Exemple #6
0
    public void actionPerformed(ActionEvent e) {
      JFileChooser chooser = new JFileChooser();
      chooser.setDialogTitle("SaveAs");
      int choice = 0;
      do {
        int result = chooser.showOpenDialog(null);
        if (result == JFileChooser.APPROVE_OPTION) {
          file = chooser.getSelectedFile();
          try {
            if (file != null) {
              fileName = file.getCanonicalPath();
              printWriter = new PrintWriter(new FileOutputStream(fileName), true);
            }
            printWriter.append(responseArea.getText());
            choice = 2;

          } catch (IOException c) {
            c.printStackTrace();
            Object[] options = new String[] {"Choose New File", "Exit"};
            choice =
                JOptionPane.showOptionDialog(
                    null,
                    "Invalid FileChoosen." + "Would you like to choose a new file " + "or exit?",
                    "Options",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.ERROR_MESSAGE,
                    null,
                    options,
                    options[0]);
            if (choice == 1) System.exit(0);
          }
        } else if (result == JFileChooser.CANCEL_OPTION) {
          Object[] options = new String[] {"Choose Different File", "Exit"};
          choice =
              JOptionPane.showOptionDialog(
                  null,
                  "Would you like to choose a new file " + " or exit?",
                  "Options",
                  JOptionPane.YES_NO_OPTION,
                  JOptionPane.ERROR_MESSAGE,
                  null,
                  options,
                  options[0]);
          if (choice == 1) System.exit(0);
        }
      } while (choice == 0);
      printWriter.flush();
      printWriter.close();
    }
  @Override
  public void actionPerformed(ActionEvent e) {

    Object[] options = {"Cancel", "No!", "Ok"};
    int n =
        JOptionPane.showOptionDialog(
            Application.get(),
            "<html>Would you like to <b>delete</b> the selected data layer?",
            "Delete values from heatmap",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            options,
            options[2]);

    if (n == 1 | n == 0) {
      return;
    }

    AbstractCommand cmd =
        new AbstractCommand() {

          @Override
          public void execute(IProgressMonitor monitor) throws CommandException {

            getHeatmap().removeLayer(layer);
          }
        };

    JobThread.execute(Application.get(), cmd);
    Application.get().showNotification("Data layer deleted");
  }
  protected void setDefaultSpeeds(JFrame _who) {
    JComboBox<String> blockSpeedCombo = new JComboBox<String>(speedList);
    blockSpeedCombo.setEditable(true);

    JPanel block = new JPanel();
    block.add(new JLabel("Block Speed"));
    block.add(blockSpeedCombo);

    blockSpeedCombo.removeItem(defaultBlockSpeedText);

    blockSpeedCombo.setSelectedItem(InstanceManager.blockManagerInstance().getDefaultSpeed());

    int retval =
        JOptionPane.showOptionDialog(
            _who,
            "Select the default values for the speeds through the blocks\n",
            "Block Speeds",
            0,
            JOptionPane.INFORMATION_MESSAGE,
            null,
            new Object[] {"Cancel", "OK", block},
            null);
    if (retval != 1) {
      return;
    }

    String speedValue = (String) blockSpeedCombo.getSelectedItem();
    // We will allow the turnout manager to handle checking if the values have changed
    try {
      InstanceManager.blockManagerInstance().setDefaultSpeed(speedValue);
    } catch (jmri.JmriException ex) {
      JOptionPane.showMessageDialog(null, ex.getMessage() + "\n" + speedValue);
      return;
    }
  }
 protected RosterEntry[] selectRosterEntry(String rosterGroup) {
   // create a dialog to select the roster entry
   JComboBox<?> selections = new RosterEntryComboBox(rosterGroup);
   int retval =
       JOptionPane.showOptionDialog(
           _who,
           "Select one roster entry",
           "Delete roster entry",
           0,
           JOptionPane.INFORMATION_MESSAGE,
           null,
           new Object[] {"Cancel", "OK", selections},
           null);
   log.debug(
       "Dialog value "
           + retval
           + " selected "
           + selections.getSelectedIndex()
           + ":"
           + selections.getSelectedItem());
   if (retval != 1) {
     return null;
   }
   RosterEntry[] entries = new RosterEntry[1];
   entries[0] = (RosterEntry) selections.getSelectedItem();
   return entries;
 }
Exemple #10
0
 protected void handleModified() {
   if (Setup.isAutoSaveEnabled()) {
     storeValues();
     return;
   }
   if (OperationsXml.areFilesDirty()) {
     int result =
         javax.swing.JOptionPane.showOptionDialog(
             this,
             Bundle.getMessage("PromptQuitWindowNotWritten"),
             Bundle.getMessage("PromptSaveQuit"),
             javax.swing.JOptionPane.YES_NO_OPTION,
             javax.swing.JOptionPane.WARNING_MESSAGE,
             null, // icon
             new String[] {
               ResourceBundle.getBundle("jmri.util.UtilBundle").getString("WarnYesSave"), // NOI18N
               ResourceBundle.getBundle("jmri.util.UtilBundle").getString("WarnNoClose")
             }, // NOI18N
             ResourceBundle.getBundle("jmri.util.UtilBundle").getString("WarnYesSave"));
     if (result == javax.swing.JOptionPane.NO_OPTION) {
       return;
     }
     // user wants to save
     storeValues();
   }
 }
 public static Map<String, Object> mensajeError(Exception e, String nombreClase) {
   JLabel jlMensaje =
       new JLabel(
           "<html>Lo sentimos, hemos detectado un error interno.<br/><br/>"
               + "<font size=5>¿Desea informar este problema?</font><br/><br/>"
               + "Se ha creado un informe de error que puede enviar para mejorar ShrimSoft.<br/>"
               + "Adicionalmente puede detallarnos sobre que provocó este error.</html>");
   JTextArea jtaMensaje = new JTextArea();
   jtaMensaje.setRows(6);
   jtaMensaje.setColumns(40);
   Object[] comp = {jlMensaje, jtaMensaje};
   Object[] botones = {"Enviar informe de error", "Cancelar"};
   int i =
       JOptionPane.showOptionDialog(
           null,
           comp,
           "ShrimSoft",
           JOptionPane.YES_NO_OPTION,
           JOptionPane.ERROR_MESSAGE,
           UIManager.getIcon("OptionPane.errorIcon"),
           botones,
           null);
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("opcion", i);
   map.put("mensaje", jtaMensaje.getText());
   return map;
 }
Exemple #12
0
  /**
   * Display an exception in a nice user-oriented way. Instead of displaying the whole stack trace,
   * just display the exception message and a button for displaying the whole stack trace.
   */
  public static void showException(Component parent, Exception e, String info) {
    Object[] message = new Object[1];
    String string;

    if (info != null) {
      string = info + "\n" + e.getMessage();
    } else {
      string = e.getMessage();
    }

    message[0] = ellipsis(string, 400);

    Object[] options = {"Dismiss", "Display Stack Trace"};

    // Show the MODAL dialog
    int selected =
        JOptionPane.showOptionDialog(
            parent,
            message,
            "Exception Caught",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE,
            null,
            options,
            options[0]);

    if (selected == 1) {
      showStackTrace(parent, e, info);
    }
  }
    /*
     * Don't need to implement this method unless your table's
     * data can change.
     */
    public void setValueAt(Object value, int row, int col) {
      double newVal = Double.parseDouble(value.toString());
      newVal = newVal > 0 ? newVal : 0;
      if (col == 1 && (newVal < lowestTemp || newVal > highestTemp)) {
        Object[] options = {"Yes, use value", "No, that is a mistake"};
        int n =
            JOptionPane.showOptionDialog(
                null,
                "Value entered, "
                    + newVal
                    + "(F), is not between "
                    + lowestTemp
                    + "(F) and "
                    + highestTemp
                    + "(F)",
                "Verify entry",
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null,
                options,
                options[1]);
        if (n == 1) {
          return;
        }
      }

      data[row][col] = new DecimalFormat("000").format(newVal);
      fireTableCellUpdated(row, col);
      // graph.onCycleStart(0,getCurrentCycleConfig());
    }
Exemple #14
0
  public static String ageCondition() {

    String age = JOptionPane.showInputDialog("Enter an Age:");
    String[] choices = {"Less than", "Less than/Equal to", "Greater than", "Greater than/Equal to"};
    String query = null;

    int choice = 0;

    choice =
        JOptionPane.showOptionDialog(
            null, "Main Menu", "Main Menu", 0, JOptionPane.QUESTION_MESSAGE, null, choices, "null");
    switch (choice) {
      case 0:
        query = "age < " + age;
        break;
      case 1:
        query = "age <= " + age;
        break;
      case 2:
        query = "age > " + age;
        break;
      case 3:
        query = "age >= " + age;
        break;
    }

    return query;
  }
  /**
   * Method for the button OK
   *
   * @param evt
   */
  private void jButton4ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton4ActionPerformed
    int getOK;
    try {

      BigDecimal firstPayment = new BigDecimal(tfGetFirstPaymentAmount.getText());
      BigDecimal saleAmount = new BigDecimal(tfGetSaleAmount.getText());
      Date date = boxSaleDate.getSelectedDate().getTime();
      setSale(date, saleAmount, firstPayment, customer);
      confirmSale();

      Object[] options = {"Onayla", "Geri"};
      getOK =
          JOptionPane.showOptionDialog(
              this,
              "Satışı  Onaylıyor musunuz?\n" + sale.printRecipe(),
              "Satış Onay",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              options,
              options[0]);

      if (getOK == 0) { // Payment Confirmed by the user
        DatabaseOperations.saveSale(sale);
        JOptionPane.showMessageDialog(this, "Satış işlemi  başarıyla gerçekleştirildi.");
        this.dispose();
      }

    } catch (NumberFormatException ex) {
      JOptionPane.showMessageDialog(this, "Ödeme tutarı hatalı!\nLütfen kontrol ediniz.");
    } catch (SQLException ex) {
      JOptionPane.showMessageDialog(this, "İşlem gerçekleştirelemedi!!");
    }
  } // GEN-LAST:event_jButton4ActionPerformed
Exemple #16
0
  protected static void startupDebug() {
    debugFired = true;
    debugmsg = true;

    Object[] options = {"Disable", "Enable"};

    int retval =
        JOptionPane.showOptionDialog(
            null,
            "Start JMRI with Logix enabled or disabled?",
            "Start Up",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            options,
            options[0]);

    if (retval != 0) {
      debugmsg = false;
      return;
    }
    InstanceManager.logixManagerInstance().setLoadDisabled(true);
    log.info("Requested loading with Logixs disabled.");
    debugmsg = false;
  }
  /**
   * Checks to see if the sketch has been modified, and if so, asks the user to save the sketch or
   * cancel the export. This prevents issues where an incomplete version of the sketch would be
   * exported, and is a fix for <A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=157">Bug
   * 157</A>
   */
  protected boolean handleExportCheckModified() {
    if (sketch.isModified()) {
      Object[] options = {"OK", "Cancel"};
      int result =
          JOptionPane.showOptionDialog(
              this,
              "Save changes before export?",
              "Save",
              JOptionPane.OK_CANCEL_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              options,
              options[0]);

      if (result == JOptionPane.OK_OPTION) {
        handleSave(true);

      } else {
        // why it's not CANCEL_OPTION is beyond me (at least on the mac)
        // but f-- it.. let's get this s***e done..
        // } else if (result == JOptionPane.CANCEL_OPTION) {
        statusNotice("Export canceled, changes must first be saved.");
        // toolbar.clear();
        return false;
      }
    }
    return true;
  }
Exemple #18
0
  public static void main(String[] args) {
    createConnection();
    JFrame frm = new JFrame();

    Object[] options = {"Admin", "User", "Exit"};
    int selection =
        JOptionPane.showOptionDialog(
            frm,
            "Choose run mode:",
            "Untidaled",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            options,
            options[2]);

    frm.dispose();
    switch (selection) {
      case 0:
        // Run as admin.
        map = new WorldMap(true);
        break;
      case 1:
        // Run as user.
        map = new WorldMap(false);
        break;
      case 2:
        System.exit(0);
        break;
    }
  }
  public static Evenement faireChoix(Evenement a, Evenement b) {
    Object[] options = new Object[2];
    String ask, titre;

    if (b == null) {
      options[0] = "Oui";
      options[1] = "Non";
      ask = "Souhaitez vous " + a + " ?";
      titre = "Mise en Vente";
    } else {
      options[0] = "Le premier";
      options[1] = "Le second";
      ask = "Que choisissez vous entre : \n\t- " + a + "Et : \n\t- " + b + "\n?";
      titre = "Faire un choix";
    }
    int choix =
        JOptionPane.showOptionDialog(
            null,
            ask,
            titre,
            JOptionPane.DEFAULT_OPTION,
            JOptionPane.WARNING_MESSAGE,
            null,
            options,
            options[0]);
    if (choix == 0) return a;
    return b;
  }
  /**
   * This notifies the user that they are about to lose entered data (i.e. they've made changes and
   * are about to a) change classes or b) go to another entry), and allows them to save their data
   * if they so choose...
   */
  public void checkForUnsavedChanges() {
    if (dataSource == null || dataSource.isActive() == false)
      return; // no point prompting - nothing to save with!

    /*
     *    Only ever check the entry once (sometimes promptForSave can be called
     *    multiple time - remember that the 'save' function gets called by a
     *    separate thread).
     */

    if (tableData.changedByUser()) {
      String save = CBIntText.get("Save");
      String discard = CBIntText.get("Discard");

      int result =
          JOptionPane.showOptionDialog(
              owner,
              CBIntText.get("Submit changes to the Directory?"),
              CBIntText.get("Save Data"),
              JOptionPane.DEFAULT_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              new Object[] {save, discard},
              save);
      if (result == 0) {
        writeTableData(); // nb - this queues a request to the directory
      }
    }
  }
 private void btn_submeterActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btn_submeterActionPerformed
   try {
     if (!this.controller.validarSubmissao()) {
       throw new NullPointerException("A submissão já se encontra submetida.");
     }
     String opcoes[] = {"Sim", "Não"};
     int resposta =
         JOptionPane.showOptionDialog(
             null,
             "Pretende submeter o artigo?",
             "Submeter artigo",
             0,
             JOptionPane.QUESTION_MESSAGE,
             null,
             opcoes,
             opcoes[0]);
     if (resposta == 0) {
       this.controller.adicionarSubmissao();
     }
     dispose();
   } catch (IllegalArgumentException ex) {
     JOptionPane.showMessageDialog(
         this, ex.getMessage(), "Submeter Artigo", JOptionPane.ERROR_MESSAGE);
   } catch (NullPointerException ex) {
     JOptionPane.showMessageDialog(
         this, ex.getMessage(), "Submeter Artigo", JOptionPane.ERROR_MESSAGE);
     dispose();
   }
 } // GEN-LAST:event_btn_submeterActionPerformed
  private void btnDeleteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeleteActionPerformed
    Connection AllTheConnections = getConnection();
    Statement statement = null;
    String[] choices = {"Confirm Delete", "Cancel"};
    String DeptID = txtDeptID.getText();

    int response =
        JOptionPane.showOptionDialog(
            null,
            "Are you sure you want to delete?",
            "DELETE",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.PLAIN_MESSAGE,
            null,
            choices,
            null);

    if (response == JOptionPane.YES_OPTION) {
      try {
        String deleteProduct = "DELETE FROM Departments " + "WHERE Department_ID = ?";
        PreparedStatement ps = AllTheConnections.prepareStatement(deleteProduct);
        ps.setString(1, DeptID);
        int count = ps.executeUpdate();
        JOptionPane.showConfirmDialog(
            rootPane, "Successful", "Deletion was successful", JOptionPane.PLAIN_MESSAGE);

      } catch (SQLException ex) {
        // Logger.getLogger(DepartmentsGUI.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(rootPane, ex);
      }
    }
  } // GEN-LAST:event_btnDeleteActionPerformed
  @Override
  public boolean validateOperator(
      final boolean showErrors, final HashSet<Operator> visited, final Object data) {
    if (this.succeedingOperators.size() < 2) {
      JOptionPane.showOptionDialog(
          this.panel.getVisualEditor(),
          "A multiinput operator must have at least two child!",
          "Error",
          JOptionPane.DEFAULT_OPTION,
          JOptionPane.ERROR_MESSAGE,
          null,
          null,
          null);

      return false;
    }

    for (final OperatorIDTuple<Operator> opIDT : this.succeedingOperators) {
      if (!opIDT.getOperator().validateOperator(showErrors, visited, data)) {
        return false;
      }
    }

    return true;
  }
  public static void main(String[] args) {

    /*
     * PIECE=WHITE/black pawn=P/p kinght (horse)=K/k bishop=B/b rook
     * (castle)=R/r Queen=Q/q King=A/a
     *
     * (1234b represents row1,column2 moves to row3, column4 which captured
     * b (a space represents no capture))
     */

    JFrame frame = createFrame();
    Object[] whiteOptions = {"Computer", "Human"};
    humanAsWhite =
        JOptionPane.showOptionDialog(
                    null,
                    "Who should play as white?",
                    "",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    whiteOptions,
                    whiteOptions[1])
                == 0
            ? false
            : true;
    if (!humanAsWhite) {
      makeFirstComputerMove(frame);
    }
  }
Exemple #25
0
 /**
  * Método que pide confirmación al usuario antes de salir de la aplicación.
  *
  * @param e El evento generado.
  * @return Si se puede salir o no (elección del usuario).
  */
 public boolean canExit(EventObject e) {
   // Si se ha modificado el modelo, pedir confirmación de salida
   if (DelphSimApp.getApplication().getInterfaz().getArchivoModificado()) {
     org.jdesktop.application.ResourceMap resourceMap =
         org.jdesktop.application.Application.getInstance(delphsim.DelphSimApp.class)
             .getContext()
             .getResourceMap(DelphSimView.class);
     Object source = (e != null) ? e.getSource() : null;
     Component owner = (source instanceof Component) ? (Component) source : null;
     String[] opciones = {"Sí", "No"};
     int option =
         JOptionPane.showOptionDialog(
             owner,
             resourceMap.getString("ExitListener.msg"),
             resourceMap.getString("ExitListener.title"),
             JOptionPane.YES_NO_OPTION,
             JOptionPane.WARNING_MESSAGE,
             null,
             opciones,
             opciones[1]); // NOI18N
     return option == JOptionPane.YES_OPTION;
   } else {
     return true;
   }
 }
 private int mergeText() {
   int option =
       JOptionPane.showOptionDialog(
           null,
           "merge text into image?",
           "merge?",
           JOptionPane.YES_NO_CANCEL_OPTION,
           JOptionPane.QUESTION_MESSAGE,
           getMainFrame().smallLogo,
           null,
           null);
   switch (option) {
     case JOptionPane.YES_OPTION:
       setUpUndo(ImageProcessor.copyImage(getImage()));
       if (text != null) {
         drawTextToImage();
       }
       internalFrame.setModifiedTitle();
       getMainFrame().updateEditMenuStatus();
     case JOptionPane.CANCEL_OPTION:
       setText(null, null);
       setStart(null);
       break;
   }
   return option;
 }
  private void doMergeImage() {
    if (pastedImage != null) {
      int option =
          JOptionPane.showOptionDialog(
              null,
              "merge images?",
              "merge?",
              JOptionPane.YES_NO_CANCEL_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              getMainFrame().smallLogo,
              null,
              null);

      switch (option) {
        case JOptionPane.YES_OPTION:
          setUpUndo(ImageProcessor.copyImage(getImage()));
          mergePastedImage();
          internalFrame.setModifiedTitle();
          getMainFrame().updateEditMenuStatus();
        case JOptionPane.CANCEL_OPTION:
          setPastedImage(null);
          setStart(null);
          break;
      }
    }
  }
Exemple #28
0
 public boolean close() throws IOException {
   if (isDirty()) {
     Object[] options = {
       SikuliIDEI18N._I("yes"), SikuliIDEI18N._I("no"), SikuliIDEI18N._I("cancel")
     };
     int ans =
         JOptionPane.showOptionDialog(
             this,
             SikuliIDEI18N._I("msgAskSaveChanges", getCurrentShortFilename()),
             SikuliIDEI18N._I("dlgAskCloseTab"),
             JOptionPane.YES_NO_CANCEL_OPTION,
             JOptionPane.WARNING_MESSAGE,
             null,
             options,
             options[0]);
     if (ans == JOptionPane.CANCEL_OPTION || ans == JOptionPane.CLOSED_OPTION) {
       return false;
     } else if (ans == JOptionPane.YES_OPTION) {
       if (saveFile() == null) {
         return false;
       }
     } else {
       SikuliIDE.getInstance().getTabPane().resetLastClosed();
     }
     if (_srcBundleTemp) {
       FileManager.deleteTempDir(_srcBundlePath);
     }
     setDirty(false);
   }
   if (_srcBundlePath != null) {
     ImagePath.remove(_srcBundlePath);
   }
   return true;
 }
 private void botaoInserirActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_botaoInserirActionPerformed
   try {
     String[] opcoes = {"sim", "não"};
     String rg = JOptionPane.showInputDialog("Digite seu RG");
     controllerCliente = new ClienteControllerUI();
     if (controllerCliente.clienteExiste(Long.parseLong(rg))) {
       int op =
           JOptionPane.showOptionDialog(
               this,
               "Deseja alugar este livro?",
               "Cliente encontrado!",
               JOptionPane.YES_NO_OPTION,
               JOptionPane.QUESTION_MESSAGE,
               null,
               opcoes,
               opcoes[0]);
       if (op == 0) {
         JOptionPane.showMessageDialog(this, "Processando Dados...");
         controller.salvarAluguel(Long.parseLong(rg));
       } else {
         JOptionPane.showMessageDialog(this, "Livro não pode ser alugado!");
       }
     } else {
       JOptionPane.showMessageDialog(this, "Cliente não encontrado!");
     }
   } catch (Exception e) {
     JOptionPane.showMessageDialog(this, "Campo inválido!");
   }
 } // GEN-LAST:event_botaoInserirActionPerformed
 public void actionPerformed(ActionEvent event) {
   if (typePanel.getSelection().equals("Confirm"))
     JOptionPane.showConfirmDialog(
         OptionDialogFrame.this,
         getMessage(),
         "Title",
         getType(optionTypePanel),
         getType(messageTypePanel));
   else if (typePanel.getSelection().equals("Input")) {
     if (inputPanel.getSelection().equals("Text field"))
       JOptionPane.showInputDialog(
           OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel));
     else
       JOptionPane.showInputDialog(
           OptionDialogFrame.this,
           getMessage(),
           "Title",
           getType(messageTypePanel),
           null,
           new String[] {"Yellow", "Blue", "Red"},
           "Blue");
   } else if (typePanel.getSelection().equals("Message"))
     JOptionPane.showMessageDialog(
         OptionDialogFrame.this, getMessage(), "Title", getType(messageTypePanel));
   else if (typePanel.getSelection().equals("Option"))
     JOptionPane.showOptionDialog(
         OptionDialogFrame.this,
         getMessage(),
         "Title",
         getType(optionTypePanel),
         getType(messageTypePanel),
         null,
         getOptions(),
         getOptions()[0]);
 }