@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); } }
@SuppressWarnings("unchecked") private void onLinkClick(ActionEvent e) { e = e.copyFor(LinkTableColumn.this, e.getTarget()); LinkTableColumn.this .getOnAction() .handle(new ColumnClickEvent<S, T>(e, ((S) this.getTableRow().getItem()), getItem())); }
@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); } }
@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()); } } }
@FXML void onColorButtonAction(ActionEvent event) { final ToggleButton tb = (ToggleButton) event.getTarget(); assert tb == colorToggleButton; final Color value = colorPicker.getValue(); // Update UI setMode(value); // Update model setPaintProperty(value); event.consume(); }
@FXML void onRadialButtonAction(ActionEvent event) { final ToggleButton tb = (ToggleButton) event.getTarget(); assert tb == radialToggleButton; final Paint value = gradientPicker.getValue(Mode.RADIAL); assert value instanceof RadialGradient; // Update UI setMode(value); gradientPicker.setMode(value); gradientPicker.updatePreview(value); // Update model setPaintProperty(value); event.consume(); }
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); } }
@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 { } } }
@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 } }); }
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; } }
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 = ""; } }
/** * @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()); } }
private void handleButtonAction(ActionEvent event) throws IOException { Button b = (Button) event.getSource(); if (b.getText().equals("Yes")) { answer = 1; } else { answer = 2; } }
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(); }
@FXML void cofnij(ActionEvent event) { try { ((Node) (event.getSource())).getScene().getWindow().hide(); } catch (Exception e) { Main.logger.log(Level.SEVERE, e.toString()); } }
// 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 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(); }
@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"); } }
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(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); } } } }
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); }
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); } }
@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)); }
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(); } }
@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()); } }
/** * 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); }
/** * 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); }
@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"); } }
@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 } }); }
@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); } } } }