public static boolean display(String title, String message) {
    Stage window = new Stage();
    window.initModality(Modality.APPLICATION_MODAL);

    Label l1 = new Label(message);

    // Create 2 buttons
    Button yesBtn = new Button("Yes");
    Button noBtn = new Button("No");

    yesBtn.setOnAction(
        e -> {
          ans = true;
          window.close();
        });

    noBtn.setOnAction(
        e -> {
          ans = false;
          window.close();
        });

    HBox hbox = new HBox(10);
    hbox.getChildren().addAll(l1, yesBtn, noBtn);
    hbox.setAlignment(Pos.CENTER);

    Scene sc = new Scene(hbox);

    window.setScene(sc);
    window.setTitle(title);
    window.setMinWidth(250);
    window.showAndWait();

    return ans;
  }
Beispiel #2
0
  public void storeLogin() {
    Stage window = new Stage();
    Button button;
    String password = "******";

    Label label = new Label("Please enter the store password");

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Store Login");
    window.setWidth(300);
    window.setHeight(200);

    final TextField passWordInput = new TextField();
    button = new Button("Enter");
    button.setOnAction(
        e -> {
          String entry = passWordInput.getText();
          if (entry.equalsIgnoreCase(password)) {
            answer = true;
            window.close();
          } else {
            answer = false;
            window.close();
          }
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, passWordInput, button);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
  public static boolean display(String title, String message) {
    Stage window = new Stage();
    answer = false;

    // Block events to other windows. means don't allow control of the first window untill this
    // window is closed.
    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle(title);
    window.setMinWidth(250);

    Label label = new Label();
    label.setText(message);

    // Create two buttons
    Button yesButton = new Button("Yes");
    Button noButton = new Button("No");
    yesButton.setOnAction(
        e -> {
          answer = true;
          window.close();
        });
    noButton.setOnAction(e -> window.close());

    VBox layout = new VBox(10);
    layout.getChildren().addAll(label, yesButton, noButton);
    layout.setAlignment(Pos.CENTER);

    // Display window and wait for it to be closed before returning
    Scene scene = new Scene(layout);
    window.setScene(scene);
    //        window.show();
    window.showAndWait(); // show the window & wait unitl it's closed

    return answer;
  }
 public static void tradePlayers(
     BaseballCard cardOne,
     BaseballCard cardTwo,
     int positionFrom,
     int positionTo,
     String selectionFrom,
     String selectionTo,
     Stage s) {
   Label label =
       new Label(
           playerInfo(cardOne)
               + " at index "
               + positionFrom
               + "(Collection"
               + selectionFrom
               + ") "
               + " has been traded to Collection "
               + selectionTo
               + " at position "
               + positionTo
               + " in exchange for "
               + playerInfo(cardTwo));
   Scene scene = new Scene(label);
   Stage stage = new Stage();
   stage.setTitle("Traded Players");
   stage.setScene(scene);
   stage.show();
   s.close();
 }
Beispiel #5
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 {
     }
   }
 }
Beispiel #6
0
 public void createEvents() {
   closeButton.setOnAction(
       event -> {
         NetWindow = (Stage) closeButton.getScene().getWindow();
         NetWindow.close();
       });
 }
Beispiel #7
0
  public void storeEntry() {
    Stage window = new Stage();
    Button button;

    Label label = new Label("Please enter the item UPC");
    Label label2 = new Label("Please enter the item's location");

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Save an item");
    window.setWidth(300);
    window.setHeight(400);

    final TextField upcInput = new TextField();
    final TextField locationInput = new TextField();
    button = new Button("Save");
    button.setOnAction(
        e -> {
          try {
            itemUPC = Double.parseDouble(upcInput.getText());
            itemLOC = locationInput.getText();
          } catch (Exception f) {
            displaySimple("Bad input", "Please enter valid inputs");
            status = false;
          }
          window.close();
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, upcInput, label2, locationInput, button);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
  @FXML
  private void onOkButtonClicked() {

    if (!headerTextField.getText().isEmpty() || picturePreview.getImage() != null) {
      HTMLHeader header;
      if (!headerTextField.getText().isEmpty() && picturePreview.getImage() == null) {
        header = new HTMLHeader(headerTextField.getText());
        System.out.println("Header only has text.");
      } else if (headerTextField.getText().isEmpty() && picturePreview.getImage() != null) {
        header = new HTMLHeader(picturePreview.getImage());
        System.out.println("Header only has image.");
      } else {
        header = new HTMLHeader(headerTextField.getText(), picturePreview.getImage());
        System.out.println("Header has both image and text.");
      }

      ApplicationManager.getInstance().setWebPageHeader(header);
      System.out.println("Attempting to set header to webpage.");
      // --------------------Added By James------------------------------------------------
      // JavaToHTML HTML = new JavaToHTML();
      // ApplicationManager.getInstance().getHtmlGenerator().setHeaderFromGUI(headerTextField.getText(),picturePath.getText());
      // writeAndRefresh();
      // --------------------End Added By James------------------------------------------------
    } else {
      System.out.println("Header has nothing. Not creating an object.");
    }
    Stage stage = (Stage) okButton.getScene().getWindow();

    stage.close();
  }
Beispiel #9
0
  @Override
  public void handle(KeyEvent event) {
    if (!(event.getSource() instanceof TextArea)) {
      return;
    }
    if (System.currentTimeMillis() - lastCommandTime < 200) {
      return;
    }
    final Stage dialog = new Stage();
    final StackPane pane = new StackPane();
    dialog.setScene(new Scene(pane));
    final VBox vbox = new VBox();
    pane.getChildren().add(vbox);

    vbox.setAlignment(Pos.CENTER);
    vbox.getChildren().add(new Label());
    vbox.getChildren().add(new Label("   hey! ツラタン...   "));
    vbox.getChildren().add(new Label());
    final Button bottom = new Button();
    bottom.setText("OK");
    bottom.setOnAction(
        boxEvent -> {
          dialog.close();
        });
    vbox.getChildren().add(bottom);
    vbox.getChildren().add(new Label(""));
    dialog.showAndWait();
    lastCommandTime = System.currentTimeMillis();
  }
  private void showError(List<String> errorList) {
    String msg = "";
    if (errorList.isEmpty()) {
      msg = "No message to display.";
    } else {
      for (String s : errorList) {
        msg = msg + s + "\n";
      }
    }
    Label msgLbl = new Label(msg);
    Button okBtn = new Button("OK");
    VBox root = new VBox(new StackPane(msgLbl), new StackPane(okBtn));
    root.setSpacing(10);

    Scene scene = new Scene(root);
    Stage stage = new Stage(StageStyle.UTILITY);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.setScene(scene);
    stage.initOwner(view.getScene().getWindow());

    // Set the Action listener for the OK button
    okBtn.setOnAction(e -> stage.close());

    stage.setTitle("Error");
    stage.sizeToScene();
    stage.showAndWait();
  }
Beispiel #11
0
  public void customerEntry() {
    Stage window = new Stage();
    Button button;

    Label label = new Label("Please enter the item you are searching for");
    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Find an item");
    window.setWidth(400);
    window.setHeight(400);

    final TextField nameInput = new TextField();
    button = new Button("Find");
    button.setOnAction(
        e -> {
          try {
            userEntry = nameInput.getText();
          } catch (Exception f) {
            displaySimple("Bad input", "Please enter valid inputs");
            status = false;
          }
          window.close();
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, nameInput, button);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
  static void display(String title) {
    Stage window = new Stage();
    StackPane layout = new StackPane();
    Scene scene = new Scene(layout, 300, 150);

    Button btnFile = new Button("File");
    btnFile.setMaxHeight(Double.MAX_VALUE);
    btnFile.setMaxWidth(Double.MAX_VALUE);

    Button btnEdit = new Button("Edit");
    btnEdit.setMaxHeight(Double.MAX_VALUE);
    btnEdit.setMaxWidth(Double.MAX_VALUE);

    Button btnSave = new Button("Save");
    btnSave.setMaxHeight(Double.MAX_VALUE);
    btnSave.setMaxWidth(Double.MAX_VALUE);

    Button btnClose = new Button("close");
    btnClose.setOnAction(e -> window.close());

    VBox vBox = new VBox();
    vBox.getChildren().addAll(btnFile, btnEdit, btnSave, btnClose);
    vBox.setVgrow(btnFile, Priority.ALWAYS);
    vBox.setVgrow(btnEdit, Priority.ALWAYS);
    vBox.setVgrow(btnSave, Priority.ALWAYS);
    vBox.setAlignment(Pos.CENTER);

    layout.getChildren().add(vBox);

    window.setTitle(title);
    window.setScene(scene);
    window.show();
  }
  public void sendRequest(String username, String password) {

    thisStage = (Stage) logInButton.getScene().getWindow();
    Response res =
        new Request("user/login").set("username", username).set("password", password).send();

    if (res.getSuccess()) {
      Main.setSessionID((String) res.get("sessionID"));
      System.out.println("Login successful.");
      Main.userNotLoggedIn.setValue(false);

      // Save the login option if checked
      if (keepMeLoggedInCheckBox.isSelected()) {
        pc.setProp("username", usernameTextField.getText());
        pc.setProp("password", passwordPasswordField.getText());
        pc.setProp("signInCheckbox", "true");
        pc.saveProps();
      }

      HomeController.userName = usernameTextField.getText();
      thisStage.close();
    } else {
      // incorrect password
    }
  }
  public void initialize() throws IOException {

    lblMessage.setText("");
    lblMessage.setText("Send Oil Change Reminder Message?");

    btnCancelMessage.setOnAction(
        e -> {
          // System.exit(0);
          Stage stageBox = (Stage) btnCancelMessage.getScene().getWindow();
          stageBox.close();
        });
    btnSendMessage.setOnAction(
        e -> {
          lblMessage.setText("");
          lblMessage.setText("Message Sent!");

          try {
            btnCancelMessage.setAlignment(Pos.CENTER);
            btnSendMessage.setVisible(false);
            btnCancelMessage.setText("Done!");
            Parent stageBox = btnCancelMessage.getParent();
            ((BorderPane) stageBox).setCenter(btnCancelMessage);
          } catch (Exception exception) {
          }
        });
  }
 @FXML
 private void onSaveButtonClick(ActionEvent event) {
   pc.setProp("jdkLocation", jdkLocationTextBox.getText());
   pc.saveProps();
   thisStage = (Stage) saveButton.getScene().getWindow();
   thisStage.close();
 }
  @FXML
  private void okPressed() {
    password = textField.getText();

    loggedIn = true;

    dialogStage.close();
  }
 @FXML
 private void close() {
   try {
     stage.close();
   } catch (Exception e) {
     ExceptionController.display(e);
   }
 }
  /** Method to close the pop up and remove the background mask. */
  public void hide() {

    Parent parentRoot = ((Stage) stage.getOwner()).getScene().getRoot();
    if (parentRoot instanceof StackPane) {
      ((StackPane) parentRoot).getChildren().remove(mask);
    }
    stage.close();
  }
 @FXML
 private void create(ActionEvent event) {
   String album = nameTextField.getText();
   PhotoStory.user.addAlbum(album);
   PhotoStory.save();
   Stage stage = (Stage) ((AnchorPane) nameTextField.getParent()).getScene().getWindow();
   stage.close();
 }
Beispiel #20
0
 public static void getCard(BaseballCard baseballCard, String selection, Stage s) {
   Label label = new Label(playerInfo(baseballCard) + " is from Collection " + selection + ".");
   Scene scene = new Scene(label);
   Stage stage = new Stage();
   stage.setTitle("Get Card");
   stage.setScene(scene);
   stage.show();
   s.close();
 }
Beispiel #21
0
 public static void removePlayer(BaseballCard removeCard, String selection, Stage s) {
   Label label =
       new Label(playerInfo(removeCard) + " has been removed from collection " + selection);
   Scene scene = new Scene(label);
   Stage stage = new Stage();
   stage.setTitle("Remove Player");
   stage.setScene(scene);
   stage.show();
   s.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());
 }
Beispiel #23
0
 private void insertCover() {
   ImageResource image = tableView.getSelectionModel().getSelectedItem();
   book.setCoverImage(image);
   new CoverpageBookProcessor().processBook(book);
   Resource coverPage = book.getGuide().getCoverPage();
   book.getSpine().addResource(coverPage, 0);
   bookBrowserManager.refreshBookBrowser();
   bookBrowserManager.selectTextItem(coverPage);
   stage.close();
 }
 @FXML
 protected void exportKml() {
   String filename = tfFilename.getCharacters().toString();
   if (filename != null) {
     KmlExport.kmlPointLayer(filename, GeoConversor.getInstance().getList());
   } else {
     // TODO: show message dialog
   }
   Stage stage = (Stage) bExport.getScene().getWindow();
   stage.close();
 }
Beispiel #25
0
  public static void showTaskProgressDialog(
      Window ownerWindow, Task task, boolean showTaskMessage) {
    final Stage dialog = new Stage();
    task.setOnSucceeded(event -> dialog.close());
    task.setOnCancelled(event -> dialog.close());
    dialog.initStyle(StageStyle.UTILITY);
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(ownerWindow);
    dialog.titleProperty().bind(task.titleProperty());
    //        dialog.setTitle(ResourceManager.getMessage("title.dialog.processing"));
    dialog.setOnCloseRequest(
        event ->
            Logger.getLogger(Dialogs.class)
                .info(ResourceManager.getMessage("notification.task.terminatedByUser")));

    ProgressBar progressBar = new ProgressBar(0);
    progressBar.progressProperty().bind(task.progressProperty());
    progressBar.setMaxWidth(Double.MAX_VALUE);
    progressBar.getStyleClass().add("dark");

    Label label = new Label(ResourceManager.getMessage("label.pleaseWaitWhile"));
    Label taskMessage = new Label();
    taskMessage.textProperty().bind(task.messageProperty());

    Button cancelButton = new Button(ResourceManager.getMessage("label.button.cancel"));
    cancelButton.setOnAction(
        event -> {
          task.cancel();
          Logger.getLogger(Dialogs.class)
              .info(ResourceManager.getMessage("notification.task.terminatedByUser"));
        });

    ButtonBar buttonBar = new ButtonBar();
    buttonBar.getButtons().add(cancelButton);

    VBox dialogVBox = new VBox();
    dialogVBox.setFillWidth(true);
    dialogVBox.setSpacing(5);
    dialogVBox.setPadding(new Insets(5));
    dialogVBox.setPrefSize(300, VBox.USE_COMPUTED_SIZE);
    dialogVBox.getChildren().add(label);
    if (showTaskMessage) {
      dialogVBox.getChildren().add(taskMessage);
    }
    dialogVBox.getChildren().add(progressBar);
    dialogVBox.getChildren().add(buttonBar);

    Scene dialogScene = new Scene(dialogVBox);
    dialogScene.getStylesheets().add(ResourceManager.getUIThemeStyle());
    dialog.setScene(dialogScene);
    dialog.setResizable(false);
    dialog.show();
  }
  private static void setButtonsActions() {
    sign_in_button.setOnAction(
        event -> {
          try {
            if ((username.getText().length() > 3) && (password.getText().length() > 3)) {
              UserData.saveData();
              UserCommands.authorization();
              synchronized (ThreadStorage.getInterfaceLauncher()) {
                ThreadStorage.getInterfaceLauncher().wait();
              }
              if (UserData.authorized) {
                loginForm.close();
                MainProgram.getMainProgram().launchForm();
              }
            } else {
              error_message_field.setText("Too short username or password");
            }
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        });

    register_button.setOnAction(
        event -> {
          try {
            if ((username.getText().length() > 3) && (password.getText().length() > 3)) {
              UserData.saveData();
              UserCommands.user_exists();
              synchronized (ThreadStorage.getInterfaceLauncher()) {
                ThreadStorage.getInterfaceLauncher().wait();
              }
              if (!user_exists) {
                CategoryForm.launchForm();
                UserCommands.register();
                synchronized (ThreadStorage.getInterfaceLauncher()) {
                  ThreadStorage.getInterfaceLauncher().wait();
                }
                if (UserData.authorized) {
                  LoginForm.closeForm();
                  MainProgram.getMainProgram().launchForm();
                }
              } else {
                error_message_field.setText("Username is already existed");
              }
            } else {
              error_message_field.setText("Too short username or password");
            }
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        });
  }
  @FXML
  private void handleOk() {
    if (isInputValid()) {
      shopping.setPrice(Double.parseDouble(priceField.getText()));
      shopping.setQuantity(Integer.parseInt(quantityField.getText()));
      shopping.setId(shopping.hashCode());
      double totalPrice = shopping.getPrice() * shopping.getQuantity();
      shopping.setTotalPrice(totalPrice);

      okClicked = true;
      dialogStage.close();
    }
  }
Beispiel #28
0
  @Override
  public void start(Stage stage) {
    // Add event handlders to the buttons
    startBtn.setOnAction(e -> runTask());
    exitBtn.setOnAction(e -> stage.close());

    HBox buttonBox = new HBox(5, startBtn, exitBtn);
    VBox root = new VBox(10, statusLbl, buttonBox);
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("An Unresponsive UI");
    stage.show();
  }
    public Scene sc(String message) {
      GridPane gp = new GridPane();
      gp.setMaxSize(150, 150);
      Button text = new Button(message);
      text.setOnAction(eventClose -> stage.close());
      text.setFont(new Font("Arial", 20));
      text.setAlignment(Pos.CENTER);
      gp.setAlignment(Pos.CENTER);
      gp.getChildren().add(text);
      Scene sc = new Scene(gp, 300, 150);

      return sc;
    }
Beispiel #30
0
  private void botaoLogar() {
    CondominoDAO dao = new CondominoDAO();
    Condomino condomino = dao.validarLogin(condominoConsulta());

    if (condomino != null) {
      Principal principal = new Principal(condomino);
      principal.setVisible(true);
      stage.close();
    } else {
      JOptionPane.showMessageDialog(
          null, "Login ou senha incorreta", "ERRO", JOptionPane.ERROR_MESSAGE);
    }
  }