Exemplo n.º 1
0
  @FXML
  private void gameSetup(ActionEvent e) throws NullPointerException {
    try {
      if (e.getSource() == nextButton) {
        numPlayer = Integer.parseInt(numPlayers.getSelectionModel().getSelectedItem().toString());
        // initializing players array
        players = new Player[numPlayer.intValue()];
        String map = mapType.getSelectionModel().getSelectedItem().toString();
        if (Objects.equals(map, "Random")) {
          try {
            gameRoot = FXMLLoader.load(getClass().getResource("UIFiles/MainMap.fxml"));
            //				RandMap.setImages();
          } catch (Exception e1) {
            e1.printStackTrace();
          }
        }
        level =
            difficulty
                .getSelectionModel()
                .getSelectedItem()
                .toString(); // "Beginner", "Standard", or "Tournament"
        Launcher.primaryStage.setScene(
            Launcher.nextScene); // Show player config screen for player 1
        Launcher.primaryStage.setTitle("Player 1 Configuration");
        count = 1;

      } else if (e.getSource() == cancelButton) {
        Launcher.primaryStage.close();
      }
    } catch (NullPointerException error) {
      Launcher.primaryStage.setScene(Launcher.errorMessage);
    }
  }
 @FXML
 private void handleButtonAction(ActionEvent event) {
   System.out.println("You selected " + event.getSource().toString());
   final String selection = ((Button) event.getSource()).getText();
   if (selection != null && !selection.equals(label.getText())) {
     label.setText(selection);
     clearAll();
     updateForSelection(selection);
   }
 }
Exemplo n.º 3
0
  @FXML
  private void handleAction(ActionEvent event) {
    TextArea textarea = (TextArea) menuBar.getScene().lookup("#textarea");

    if (event.getSource() == chmiWordWrap) {
      wordWrapOn = chmiWordWrap.isSelected();
      textarea.setWrapText(wordWrapOn);

    } else if (event.getSource() == miChangeCase) {
      try {
        if (changeCaseDialog == null) {
          FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ChangeCaseDialog.fxml"));
          Parent root = fxmlLoader.load();
          controller = fxmlLoader.getController();
          controller.setSelectedCase(prefs.get(strSelectedCase, "UPPERCASE"));
          changeCaseDialog = new Stage();
          changeCaseDialog.setResizable(false);
          changeCaseDialog.initStyle(StageStyle.UTILITY);
          changeCaseDialog.setAlwaysOnTop(true);
          changeCaseDialog.setX(prefs.getDouble(strChangeCaseX, changeCaseDialog.getX()));
          changeCaseDialog.setY(prefs.getDouble(strChangeCaseY, changeCaseDialog.getY()));
          Scene scene = new Scene(root);
          changeCaseDialog.setScene(scene);
          changeCaseDialog.setTitle("Change Case");
        }

        changeCaseDialog.toFront();
        changeCaseDialog.show();
      } catch (Exception e) {

      }
    } else if (event.getSource() == miRemoveLineBreaks) {
      if (textarea.getSelectedText().length() == 0) {
        textarea.selectAll();

        if (textarea.getSelectedText().length() == 0) {
          return;
        }
      }

      String result = TextUtilities.removeLineBreaks(textarea.getSelectedText());

      int start = textarea.getSelection().getStart();
      textarea.replaceSelection(result);
      textarea.selectRange(start, start + result.length());
    } else if (event.getSource() == miFont) {
      Font font = textarea.getFont();
      FontSelectorDialog dialog = new FontSelectorDialog(font);
      Optional<Font> op = dialog.showAndWait();
      if (op.isPresent()) {
        textarea.setFont(op.get());
      }
    }
  }
Exemplo n.º 4
0
 @FXML
 protected void handleMenuItemAction(ActionEvent ae) {
   if (ae != null
       && (ae.getSource() instanceof MenuItem || ae.getSource() instanceof CheckMenuItem)) {
     if (ae.getSource().equals(miFileProjNew)) {
       if (projectData.isOpen()) {
         // TODO: Show a message saying a project is open, what do we want to do?
         // If canceled, we abort this method, and not create the "New Project" dialog.
       }
       // If a project is not open, or was but is now closed, we can now proceed.
       actionProjectNew();
     } else if (ae.getSource().equals(miFileProjNew)) {
       // Create a new project.
     } else if (ae.getSource().equals(miFileProjOpen)) {
       // Open an existing project. Need to verify a project is not open, or if the project is
       // saved.
     } else if (ae.getSource().equals(miFileProjClose)) {
       // Close an open project.
     } else if (ae.getSource().equals(miFileProjProps)) {
       // Check the project properties.
     } else if (ae.getSource().equals(miFileExit)) {
       stage.close();
     } else {
     }
   }
 }
  public void coinTossChoice(ActionEvent event) {
    Boolean isSelected;
    // System.out.println(event.s));

    if (event.getSource().equals(chkHeads)) {
      chkTails.setSelected(false);
      btnCoinFlip.setDisable(false);
    } else if (event.getSource().equals(chkTails)) {
      chkHeads.setSelected(false);
      btnCoinFlip.setDisable(false);
    } else {
      btnCoinFlip.setDisable(true);
    }
  }
  public void actionButtonPressed(ActionEvent actionEvent) {

    Object source = actionEvent.getSource();

    // если нажата не кнопка - выходим из метода
    if (!(source instanceof Button)) {
      return;
    }

    Button clickedButton = (Button) source;
    //        System.out.println(clickedButton.getId());
    switch (clickedButton.getId()) {
      case "btnAddSite":
        System.out.println("Here 1");
        editDialogSites.setSites(new Sites());
        showDialog();
        collectionSiteBook.add(editDialogSites.getSite());
        break;

      case "btnUpdateSite":
        System.out.println("Here 2");
        editDialogSites.setSites((Sites) tableSiteBook.getSelectionModel().getSelectedItem());
        showDialog();
        break;

      case "btsDeleteSite":
        System.out.println("Here 3");
        collectionSiteBook.delete((Sites) tableSiteBook.getSelectionModel().getSelectedItem());
        break;
    }
  }
Exemplo n.º 7
0
  public void operationButtonClicked(ActionEvent e) {
    String operation;
    operation = ((Button) e.getSource()).getText();

    if (!operation.equals("=")) {
      if (!operator.isEmpty() && text.getText().split(" ").length < 2) {
        number = Double.parseDouble(text.getText().split(" ")[0]);
        text.setText(number + " " + operator + " ");
      }
      if (!operator.isEmpty() && text.getText().split(" ").length > 2) {
        double result =
            model.calculate(number, Double.parseDouble(text.getText().split(" ")[2]), operator);
        text.setText(String.valueOf(result));
      }
      operator = operation;
      number = Double.parseDouble(text.getText().split(" ")[0]);
      text.setText(number + " " + operator + " ");
    } else {
      if (operator.isEmpty()) return;
      System.out.println(text.getText().split(" ")[2]);
      double result =
          model.calculate(number, Double.parseDouble(text.getText().split(" ")[2]), operator);
      text.setText(String.valueOf(result));
      start = true;
      number = result;
      operator = "";
    }
  }
 @FXML
 private void handleExitAction(ActionEvent event) {
   final Stage owner = (Stage) ((Node) event.getSource()).getScene().getWindow();
   Dialog.showYesNo(
       "ΕΞΟΔΟΣ ΕΦΑΡΜΟΓΗΣ!",
       "Θέλετε να κλείσετε την εφαρμογή;\n\n",
       owner,
       new EventHandler<ActionEvent>() {
         @Override
         public void handle(ActionEvent t) {
           try {
             owner.close();
           } catch (Exception ex) {
             System.out.println("wrong uri again ><");
             // TODO handle error loading stage
           }
         }
       },
       new EventHandler<ActionEvent>() {
         @Override
         public void handle(ActionEvent t) {
           // Keep running
         }
       });
 }
  /**
   * @param event event of button
   * @throws GroupNotValidException not valid
   * @throws IDNotValidException not valid
   * @throws StringNotValidException not valid
   */
  public final void onBtnGroupClick(final ActionEvent event)
      throws GroupNotValidException, IDNotValidException, StringNotValidException {

    try {
      Object item = disabled.getSelectionModel().getSelectedItem();
      Button button = (Button) event.getSource();

      // add a group
      if (button.getText().equals("<<")) {

        if (item.toString().equals("Arbeit")) {
          INACTIVEDATA.remove(item);
          ACTIVEDATA.add(item);
          c.addToGroup(Main.getWorkGroup());
        }
        if (item.toString().equals("Familie")) {
          INACTIVEDATA.remove(item);
          ACTIVEDATA.add(item);
          c.addToGroup(Main.getFamilyGroup());
        }
        if (item.toString().equals("Freunde")) {
          INACTIVEDATA.remove(item);
          ACTIVEDATA.add(item);
          c.addToGroup(Main.getFriendsGroup());
        }
      }

      // remove a group
      item = enabled.getSelectionModel().getSelectedItem();
      if (button.getText().equals(">>")) {

        if (item.toString().equals("Arbeit")) {
          ACTIVEDATA.remove(item);
          INACTIVEDATA.add(item);
          c.removeFromGroup(Main.getWorkGroup());
        }
        if (item.toString().equals("Familie")) {
          ACTIVEDATA.remove(item);
          INACTIVEDATA.add(item);
          c.removeFromGroup(Main.getFamilyGroup());
        }
        if (item.toString().equals("Freunde")) {
          ACTIVEDATA.remove(item);
          INACTIVEDATA.add(item);
          c.removeFromGroup(Main.getFriendsGroup());
        }
      }

    } catch (Exception e) {

      Alert alert = new Alert(AlertType.ERROR);
      alert.setTitle("Keine gültige Gruppe erkannt.");
      alert.setHeaderText("");
      alert.setContentText("Es wurde keine gültige Gruppe erkannt. Klicke auf gültige Gruppe.");
      alert.showAndWait();

      logger.log(Level.SEVERE, "Error: " + e.getMessage());
    }
  }
 public void returnToAddStats(ActionEvent event) throws IOException {
   ((Node) (event.getSource())).getScene().getWindow().hide();
   Stage primaryStage = new Stage();
   Parent root = FXMLLoader.load(getClass().getResource("AddStatsPage.fxml"));
   Scene scene = new Scene(root);
   primaryStage.setScene(scene);
   primaryStage.show();
 }
Exemplo n.º 11
0
 private void handleButtonAction(ActionEvent event) throws IOException {
   Button b = (Button) event.getSource();
   if (b.getText().equals("Yes")) {
     answer = 1;
   } else {
     answer = 2;
   }
 }
 @FXML
 void cofnij(ActionEvent event) {
   try {
     ((Node) (event.getSource())).getScene().getWindow().hide();
   } catch (Exception e) {
     Main.logger.log(Level.SEVERE, e.toString());
   }
 }
Exemplo n.º 13
0
 @FXML
 private void handlebutton(ActionEvent event) throws IOException {
   System.out.println("hola");
   Parent paren = FXMLLoader.load(getClass().getResource("sample.fxml"));
   Scene scen = new Scene(paren);
   Stage stag = (Stage) ((Node) event.getSource()).getScene().getWindow();
   stag.hide();
   stag.setScene(scen);
   stag.show();
 }
Exemplo n.º 14
0
 // set number to text field
 public void numberButtonClicked(ActionEvent e) {
   if (start) {
     text.setText("0");
     start = false;
   }
   String a;
   a = ((Button) e.getSource()).getText();
   text.setText(text.getText() + a);
   text.positionCaret(text.getText().length());
 }
 @FXML
 private void handleBackButton(ActionEvent event) {
   try {
     Parent root = FXMLLoader.load(getClass().getResource(GAMESELECT1));
     Stage stage = ((Stage) ((Node) event.getSource()).getScene().getWindow());
     scale.scaleInterface(root);
     stage.sceneProperty().get().setRoot(root);
   } catch (IOException ex) {
     System.out.println("invalid uri");
   }
 }
 @Override
 public void handle(ActionEvent event) {
   if (event.getEventType().equals(ActionEvent.ACTION)) {
     if (event.getSource() instanceof Button) {
       Button source = (Button) event.getSource();
       if ((source.getParent().getParent() instanceof TitleView)
           && source.getId().contains("_addtask_button")) {
         handleAddTask();
       } else if ((source.getParent().getParent() instanceof TaskView)
           && !source.getId().contains("_edit_button")) {
         handleTaskOperations(source);
       } else if ((source.getParent().getParent() instanceof TitleView)
           && source.getId().contains("_edit_button")) {
         handleEditUserStory();
       } else if ((source.getParent().getParent() instanceof TaskView)
           && source.getId().contains("_edit_button")) {
         handleEditTask(source);
       }
     }
   }
 }
Exemplo n.º 17
0
  public void radioPern(ActionEvent event) {

    RadioButton o = (RadioButton) event.getSource();
    //        offertaPernotto = (OffertaPernotto)
    // accessoCatalogoModel.findOff(o.getId(),TipoOfferta.OffertaPernotto);
    offertaPernotto =
        (OffertaPernotto)
            DAOFactory.getDAOFactory(TipoOfferta.OffertaPernotto)
                .getOffertaDAO()
                .findOff(o.getId());
    accessoCatalogoView.setEffect(2, offertaPernotto.getCittà());
  }
 @Override
 public void handle(final ActionEvent event) {
   @SuppressWarnings("unchecked")
   ComboBox<String> ls = (ComboBox<String>) event.getSource();
   // ls.setCursor(new Cursor(Cursor.WAIT_CURSOR));
   String selectedItem = ls.getSelectionModel().getSelectedItem();
   System.out.println("The selected Item" + selectedItem);
   String str = wsdrlUrlTextField.getText();
   requestTextArea.setText(
       SoapUIUtil.getServiceRequestString(str, selectedItem, wireMockOptions));
   responseTextArea.setText(
       SoapUIUtil.getServiceResponseString(str, selectedItem, wireMockOptions));
 }
Exemplo n.º 19
0
 public void showTraces(ActionEvent e) {
   try {
     Button b = (Button) e.getSource();
     if (tracesPane == null) {
       tracesPane = FXMLLoader.load(getClass().getResource("/org/dynami/ui/traces/Traces.fxml"));
       tracesPopOver = new PopOver(tracesPane);
       tracesPopOver.setArrowLocation(ArrowLocation.LEFT_TOP);
     }
     tracesPopOver.show(b);
   } catch (IOException e1) {
     Execution.Manager.msg().async(Topics.INTERNAL_ERRORS.topic, e1);
   }
 }
 public void handleBackButton(ActionEvent actionEvent) {
   // Back into main page
   Parent root = null;
   try {
     root = FXMLLoader.load(getClass().getResource("sample.fxml"));
   } catch (IOException e) {
     e.printStackTrace();
   }
   Stage stage = (Stage) ((Node) actionEvent.getSource()).getScene().getWindow();
   Scene scene = new Scene(root);
   scene.getStylesheets().add(getClass().getResource("css/main_page.css").toExternalForm());
   stage.setScene(scene);
 }
Exemplo n.º 21
0
  public void logout(ActionEvent event) {
    ((Node) (event.getSource())).getScene().getWindow().hide();

    this.addLog(null, "logout");

    instance = null;
    LogInControl logInControl = new LogInControl();

    try {
      logInControl.start(new Stage());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 22
0
 /**
  * Mètode que canvia les unitats i mostra les seves dades
  *
  * @param actionEvent
  */
 public void changeUnits(ActionEvent actionEvent) {
   CheckMenuItem men = (CheckMenuItem) actionEvent.getSource();
   switch (men.getId()) {
     case "mts":
       units = 0;
       ipr.setSelected(false);
       break;
     case "ipr":
       units = 1;
       mts.setSelected(false);
       break;
   }
   setData(city, units);
 }
Exemplo n.º 23
0
 /**
  * Mètode que canvia la ciutat i mostra les seves dades
  *
  * @param actionEvent
  */
 public void changeCity(ActionEvent actionEvent) {
   CheckMenuItem men = (CheckMenuItem) actionEvent.getSource();
   switch (men.getId()) {
     case "bcn":
       city = "Barcelona";
       mdd.setSelected(false);
       break;
     case "mdd":
       city = "Madrid";
       bcn.setSelected(false);
       break;
   }
   setData(city, units);
 }
  @FXML
  public void markerChoice(ActionEvent event) {
    hboxMarkerChoice.setVisible(false);
    hboxCoinFlip.setVisible(true);
    btnCoinFlip.setDisable(true);

    if (event.getSource().equals(btnMarkerX)) {
      player.setPlayerMarker("X");
      computer.setComputerMarker("O");
    } else {
      player.setPlayerMarker("O");
      computer.setComputerMarker("X");
    }
  }
Exemplo n.º 25
0
    @Override
    public void handle(final ActionEvent event) {
      final MenuItem menuItem = (MenuItem) event.getSource();

      Application.setUserAgentStylesheet(menuItem.getUserData().toString());

      preferences.put(LAST, menuItem.getUserData().toString());

      final String current = preferences.get(LAST, null);

      if (current != null && !current.equals(menuItem.getUserData().toString())) {
        Application.setUserAgentStylesheet(menuItem.getUserData().toString());
      }
    }
 @FXML
 private void handleInstructionsAction(ActionEvent event) {
   instructions();
   Stage owner = (Stage) ((Node) event.getSource()).getScene().getWindow();
   Dialog.showInfo(
       "ΟΔΗΓΙΕΣ ΠΑΙΧΝΙΔΙΟΥ!",
       instructionsText,
       owner,
       new EventHandler<ActionEvent>() {
         @Override
         public void handle(ActionEvent t) {
           // Keep running
         }
       });
 }
Exemplo n.º 27
0
        @Override
        public void handle(ActionEvent event) {
          if (event.getSource() instanceof CheckBox) {
            for (Entry<String, CheckBox> entry : propertiesCb.entrySet()) {
              CheckBox cb = entry.getValue();
              String propertyName = entry.getKey();

              if (cb.isSelected()) {
                propertiesTf.get(propertyName).setDisable(false);
              } else {
                propertiesTf.get(propertyName).setDisable(true);
              }
            }
          }
        }
 @FXML
 private void handleButtonAction(ActionEvent event) throws IOException {
   Stage stage;
   Parent root;
   Button source = (Button) event.getSource();
   stage = (Stage) source.getScene().getWindow();
   if (source == editAbout) {
     root = FXMLLoader.load(getClass().getResource("/game/playerTurnFinished.fxml"));
   } else {
     root = null;
   }
   Scene scene = new Scene(root);
   stage.setScene(scene);
   stage.show();
 }
 public void personLinkButton(ActionEvent event) throws IOException {
   actionClose(event);
   Stage stage = new Stage();
   fxmlLoader = new FXMLLoader();
   fxmlLoader.setLocation(getClass().getResource("..\\personality.fxml"));
   Parent fxmlMain = fxmlLoader.load();
   //        Parent root =
   // FXMLLoader.load(getClass().getResource("C:\\Users\\Aleksandr\\IdeaProjects\\My_Tests\\GB_Desktop_App\\src\\sample\\keywords.fxml"));
   stage.setTitle("Справочник Личности");
   stage.setMinHeight(400);
   stage.setMinWidth(700);
   stage.setScene(new Scene(fxmlMain));
   // stage.initModality(Modality.WINDOW_MODAL);
   stage.initOwner(((Node) event.getSource()).getScene().getWindow());
   stage.show();
   System.out.println("Справочник Личности!");
   // main.primaryStage.close();
 }
 @FXML
 private void btn_actionClick(ActionEvent event) throws RuntimeException, IOException {
   Button tmp = (Button) event.getSource();
   Stage stage = (Stage) tmp.getScene().getWindow();
   if (tmp.getText().equals("<")) {
     this.edSenha.clear();
   } else if (tmp.getText().equals("OK")) {
     // entra da rotina de logar no sistema
     try {
       if (this.edSenha.getText().length() > 0) {
         AdministradorLogin al = new AdministradorLogin(GlobalInfor.admName, this.adm_password);
         if (al.login()) {
           // some com o painel de controle
           this.myController.setScreen("adm_main");
           System.out.println("Logado");
           stage.close();
         }
       } else {
         DefaultExceptionDialog de =
             new DefaultExceptionDialog("Campo de senha não pode ficar em branco.");
         de.showDialog();
         this.edSenha.setFocusTraversable(true);
       }
     } catch (LoginIncorretoException e) {
       DefaultExceptionDialog de = new DefaultExceptionDialog(e.getMessage());
       de.showDialog();
     } catch (SQLException e) {
       DefaultExceptionDialog de = new DefaultExceptionDialog("Erro no banco de dados");
       de.showDialog();
       stage.close();
     } finally {
       this.adm_password.clear();
       this.edSenha.clear();
     }
   } else {
     if (this.edSenha.getText().length() < 9) {
       this.edSenha.setText(this.edSenha.getText() + "1");
       this.adm_password.add(tmp.getText());
       this.ini_controllers();
     }
   }
   System.out.println("Debug: " + this.edSenha.getText());
 }