Java Code Examples for com.jfoenix.controls.JFXButton#setOnAction()

The following examples show how to use com.jfoenix.controls.JFXButton#setOnAction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManageWorkspacesDialog.java    From milkman with MIT License 6 votes vote down vote up
private HBox createEntry(String workspaceName) {
	
	JFXButton renameButton = new JFXButton();
	renameButton.setGraphic(new FontAwesomeIconView(FontAwesomeIcon.PENCIL, "1.5em"));
	renameButton.setTooltip(new Tooltip("Rename workspace"));
	renameButton.setOnAction(e -> triggerRenameDialog(workspaceName));
	
	JFXButton deleteButton = new JFXButton();
	deleteButton.setGraphic(new FontAwesomeIconView(FontAwesomeIcon.TIMES, "1.5em"));
	deleteButton.setTooltip(new Tooltip("Delete workspace"));
	deleteButton.setOnAction(e -> {
		onCommand.invoke(new AppCommand.DeleteWorkspace(workspaceName));
		Platform.runLater(() -> workspaces.remove(workspaceName));
	});

	JFXButton exportButton = new JFXButton();
	exportButton.setGraphic(new FontAwesomeIconView(FontAwesomeIcon.UPLOAD, "1.5em"));
	exportButton.setTooltip(new Tooltip("Export workspace"));
	exportButton.setOnAction(e -> triggerExportWorkspaceDialog(workspaceName));

	Label wsName = new Label(workspaceName);
	HBox.setHgrow(wsName, Priority.ALWAYS);
	
	return new HBox(wsName, renameButton, deleteButton, exportButton);
}
 
Example 2
Source File: ConfirmationInputDialog.java    From milkman with MIT License 6 votes vote down vote up
public ConfirmationInputDialogFxml(ConfirmationInputDialog controller){
	controller.title = new Label("title");
	setHeading(controller.title);

	controller.promptLabel = new Label();
	setBody(new VBox(controller.promptLabel));

	JFXButton apply = new JFXButton("Apply");
	apply.setDefaultButton(true);
	apply.setOnAction(e -> controller.onSave());

	JFXButton cancel = new JFXButton("Cancel");
	cancel.setCancelButton(true);
	cancel.setOnAction(e -> controller.onCancel());

	setActions(submit(controller::onSave), cancel(controller::onCancel));
}
 
Example 3
Source File: AdminAddUserViewController.java    From Corendon-LostLuggage with MIT License 6 votes vote down vote up
public void showConfirmedMessage(String headerString, String messageString, String buttonString) {
    Text header = new Text(headerString);
    header.setFont(new Font("System", 18));
    header.setFill(Paint.valueOf("#495057"));
    MESSAGE_FLOW.getChildren().clear();
    MESSAGE_FLOW.getChildren().add(new Text(messageString));
    DIALOG_LAYOUT.getActions().clear();
    DIALOG_LAYOUT.setHeading(header);
    DIALOG_LAYOUT.setBody(MESSAGE_FLOW);

    JFXButton okButton = new JFXButton(buttonString);

    okButton.setStyle("-fx-background-color: #4dadf7");
    okButton.setTextFill(Paint.valueOf("#FFFFFF"));
    okButton.setRipplerFill(Paint.valueOf("#FFFFFF"));
    okButton.setButtonType(JFXButton.ButtonType.RAISED);
    DIALOG_LAYOUT.setActions(okButton);
    okButton.setOnAction(e -> {
        alertView.close();
        stackPane.setVisible(false);
    });
}
 
Example 4
Source File: SettingsViewController.java    From Corendon-LostLuggage with MIT License 5 votes vote down vote up
private void showAlertMessage() {
    stackPane.setVisible(true);
    MESSAGE_FLOW.getChildren().clear();

    //Customize header
    Text header = new Text(alertHeader);
    header.setFont(new Font("System", 18));
    header.setFill(Paint.valueOf(headerColor));

    JFXButton hideMessageButton = new JFXButton(buttonText);
    //Customize button
    hideMessageButton.setStyle("-fx-background-color: #4dadf7");
    hideMessageButton.setTextFill(Paint.valueOf("#FFFFFF"));
    hideMessageButton.setRipplerFill(Paint.valueOf("#FFFFFF"));
    hideMessageButton.setButtonType(JFXButton.ButtonType.RAISED);

    MESSAGE_FLOW.getChildren().add(new Text(alert));
    DIALOG_LAYOUT.setHeading(header);
    DIALOG_LAYOUT.setBody(MESSAGE_FLOW);
    DIALOG_LAYOUT.setActions(hideMessageButton);
    JFXDialog alertView = new JFXDialog(stackPane, DIALOG_LAYOUT, JFXDialog.DialogTransition.CENTER);
    alertView.setOverlayClose(false);
    hideMessageButton.setOnAction(e -> {
        alertView.close();
        stackPane.setVisible(false);
    });

    alertView.show();
}
 
Example 5
Source File: DashboardController.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void createTimer() {
        // Bind the timerLabel text property to the timeSeconds property
    	timerLabel = new Label();
        timerLabel.textProperty().bind(timeSeconds.asString());
        timerLabel.setTextFill(Color.WHITE);
        //timerLabel.setStyle("-fx-font-size: 4em;");

        timeSeconds.set(STARTTIME);
        timeline = new Timeline();
        timeline.getKeyFrames().add(
                new KeyFrame(Duration.seconds(STARTTIME+1),
                new KeyValue(timeSeconds, 0)));
        timeline.playFromStart();
        
        btnRefresh = new JFXButton();
        btnRefresh.setText("Refresh");
        btnRefresh.setOnAction(e -> handleRefresh());
//        btnRefresh.setOnAction(new EventHandler<ActionEvent>() {
//
//            public void handle(ActionEvent event) {
//                if (timeline != null) {
//                    timeline.stop();
//                }
//                timeSeconds.set(STARTTIME);
//                timeline = new Timeline();
//                timeline.getKeyFrames().add(
//                        new KeyFrame(Duration.seconds(STARTTIME+1),
//                        new KeyValue(timeSeconds, 0)));
//                timeline.playFromStart();
//            }
//        });
    }
 
Example 6
Source File: OverdueNotificationController.java    From Library-Assistant with Apache License 2.0 5 votes vote down vote up
private void checkForMailServerConfig() {
    JFXButton button = new JFXButton("Okay");
    button.setOnAction((ActionEvent event) -> {
        ((Stage) rootPane.getScene().getWindow()).close();
    });
    MailServerInfo mailServerInfo = DataHelper.loadMailServerInfo();
    System.out.println(mailServerInfo);
    if (mailServerInfo == null || !mailServerInfo.validate()) {
        System.out.println("Mail server not configured");
        AlertMaker.showMaterialDialog(rootPane, contentPane, ImmutableList.of(button), "Mail server is not configured", "Please configure mail server first.\nIt is available under Settings");
    }
}
 
Example 7
Source File: DeleteDialog.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new delete dialog
 *
 * @param stage dialog stage
 */
public DeleteDialog(Stage stage) {
  super(stage);
  // set content
  body = new Text();
  HBox box = new HBox();
  box.setSpacing(10);
  box.setAlignment(Pos.CENTER);
  JFXButton delete = new JFXButton("Delete");
  delete.setGraphic(Icons.btn("trash"));
  delete.getStyleClass().add("dont-save");
  JFXButton cancel = new JFXButton("Cancel");
  cancel.setGraphic(Icons.btn("stop"));
  cancel.getStyleClass().add("cancel");
  box.getChildren().addAll(delete, cancel);
  // set layout
  JFXDialogLayout layout = new JFXDialogLayout();
  layout.setHeading(new Text("Are you sure you want to delete the selected item permanently ?"));
  layout.setBody(body);
  layout.setActions(box);
  /// set alert
  setContent(layout);
  initModality(Modality.NONE);
  setOverlayClose(false);
  setAnimation(JFXAlertAnimation.CENTER_ANIMATION);
  // save actions
  delete.setOnAction(e -> delete());
  delete.setOnKeyPressed(e -> {
    if (ENTER.match(e)) {
      delete();
    }
  });
  // cancel actions
  cancel.setOnAction(e -> cancel());
  cancel.setOnKeyPressed(e -> {
    if (ENTER.match(e)) {
      cancel();
    }
  });
}
 
Example 8
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void createMapButtons() {
	rotateCWBtn = new JFXButton();
	rotateCWBtn.setOpacity(1);
	rotateCWBtn.setGraphic(new ImageView(new Image(this.getClass().getResourceAsStream(Msg.getString("img.cw"))))); //$NON-NLS-1$
	rotateCWBtn.setStyle("-fx-background-color: transparent; ");
	setQuickToolTip(rotateCWBtn, Msg.getString("SettlementTransparentPanel.tooltip.clockwise"));
	rotateCWBtn.setOnAction(e -> {
		mapPanel.setRotation(mapPanel.getRotation() + ROTATION_CHANGE);
		e.consume();
	});

	rotateCCWBtn = new JFXButton();
	rotateCCWBtn.setOpacity(1);
	rotateCCWBtn
			.setGraphic(new ImageView(new Image(this.getClass().getResourceAsStream(Msg.getString("img.ccw"))))); //$NON-NLS-1$
	rotateCCWBtn.setStyle("-fx-background-color: transparent; ");
	setQuickToolTip(rotateCCWBtn, Msg.getString("SettlementTransparentPanel.tooltip.counterClockwise"));
	rotateCCWBtn.setOnAction(e -> {
		mapPanel.setRotation(mapPanel.getRotation() - ROTATION_CHANGE);
		e.consume();
	});

	recenterBtn = new JFXButton();
	recenterBtn.setOpacity(1);
	recenterBtn.setGraphic(
			new ImageView(new Image(this.getClass().getResourceAsStream(Msg.getString("img.recenter"))))); //$NON-NLS-1$
	recenterBtn.setStyle("-fx-background-color: transparent; ");
	setQuickToolTip(recenterBtn, Msg.getString("SettlementTransparentPanel.tooltip.recenter"));
	recenterBtn.setOnAction(e -> {
		mapPanel.reCenter();
		zoomSlider.setValue(DEFAULT_ZOOM);
		e.consume();
	});

}
 
Example 9
Source File: LogInViewController.java    From Corendon-LostLuggage with MIT License 5 votes vote down vote up
private void showAlertMessage() {
    stackPane.setVisible(true);
    MESSAGE_FLOW.getChildren().clear();

    //Customize header
    Text header = new Text(alertHeader);
    header.setFont(new Font("System", 18));
    header.setFill(Paint.valueOf(headerColor));

    JFXButton hideMessageButton = new JFXButton(buttonText);
    //Customize button
    hideMessageButton.setStyle("-fx-background-color: #4dadf7");
    hideMessageButton.setTextFill(Paint.valueOf("#FFFFFF"));
    hideMessageButton.setRipplerFill(Paint.valueOf("#FFFFFF"));
    hideMessageButton.setButtonType(JFXButton.ButtonType.RAISED);

    MESSAGE_FLOW.getChildren().add(new Text(alert));
    DIALOG_LAYOUT.setHeading(header);
    DIALOG_LAYOUT.setBody(MESSAGE_FLOW);
    DIALOG_LAYOUT.setActions(hideMessageButton);
    JFXDialog alertView = new JFXDialog(stackPane, DIALOG_LAYOUT, JFXDialog.DialogTransition.CENTER);
    alertView.setOverlayClose(false);
    hideMessageButton.setOnAction(e -> {
        alertView.close();
        stackPane.setVisible(false);
    });

    alertView.show();
}
 
Example 10
Source File: ManagerRetrievedViewController.java    From Corendon-LostLuggage with MIT License 5 votes vote down vote up
private void showAlertMessage() {
    stackPane.setVisible(true);
    MESSAGE_FLOW.getChildren().clear();

    //Customize header
    Text header = new Text(alertHeader);
    header.setFont(new Font("System", 18));
    header.setFill(Paint.valueOf(headerColor));

    JFXButton hideMessageButton = new JFXButton(buttonText);
    //Customize button
    hideMessageButton.setStyle("-fx-background-color: #4dadf7");
    hideMessageButton.setTextFill(Paint.valueOf("#FFFFFF"));
    hideMessageButton.setRipplerFill(Paint.valueOf("#FFFFFF"));
    hideMessageButton.setButtonType(JFXButton.ButtonType.RAISED);

    MESSAGE_FLOW.getChildren().add(new Text(alert));
    DIALOG_LAYOUT.setHeading(header);
    DIALOG_LAYOUT.setBody(MESSAGE_FLOW);
    DIALOG_LAYOUT.setActions(hideMessageButton);
    JFXDialog alertView = new JFXDialog(stackPane, DIALOG_LAYOUT, JFXDialog.DialogTransition.CENTER);
    alertView.setOverlayClose(false);
    hideMessageButton.setOnAction(e -> {
        alertView.close();
        stackPane.setVisible(false);
    });

    alertView.show();
}
 
Example 11
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates and returns a {@link Flyout}
 * 
 * @return a new {@link Flyout}
 */
public JFXPopup createFlyout() {
	marsNetBtn = new JFXButton();
	// marsNetBtn.getStyleClass().add("menu-button");//"button-raised");
	marsNetIcon = new IconNode(FontAwesome.COMMENTING_O);
	marsNetIcon.setIconSize(20);
	// marsNetButton.setPadding(new Insets(0, 0, 0, 0)); // Warning : this
	// significantly reduce the size of the button image
	setQuickToolTip(marsNetBtn, "Click to open MarsNet Chat Box");

	marsNetBox = new JFXPopup(createChatBox());
	marsNetBox.setOpacity(.9);

	marsNetBtn.setOnAction(e -> {
		if (!flag)
			chatBox.update();

		if (marsNetBox.isShowing()) {// .isVisible()) {
			marsNetBox.hide();// .close();
		} else {
			openChatBox();
		}
		e.consume();
	});

	return marsNetBox;
}
 
Example 12
Source File: ChatBox.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor for ChatBox
 * 
 * @param {{@link MainScene}
 */
public ChatBox(MainScene mainScene) {
	this.mainScene = mainScene;

	masterClock = sim.getMasterClock();

	this.setStyle("-fx-background-color: grey;"// #7ebcea;" //#426ab7;"//
			+ "-fx-background-color: linear-gradient(to bottom, -fx-base, derive(-fx-base,30%));"
			+ "-fx-background-radius: 3px;" + "-fx-text-fill: black;" + "-fx-border-color: white;"
			+ "-fx-border-radius: 3px;" + "-fx-border-width: 1px;" + "-fx-border-style: solid; ");

	box_height[0] = 256; // mainScene.getFlyout().getContainerHeight();
	box_height[1] = 512;// box_height[0] * 1.5D;
	box_height[2] = 768;// box_height[0] * 3D;
	box_height[3] = 1024;// box_height[0] * 4D;

	// Added autoCompleteData
	ObservableList<String> autoCompleteData = FXCollections.observableArrayList(CollectionUtils.createAutoCompleteKeywords());

	textArea = new TextArea();
	textArea.textProperty().addListener(new ChangeListener<Object>() {
	    @Override
	    public void changed(ObservableValue<?> observable, Object oldValue,
	            Object newValue) {
	    	textArea.setScrollTop(Double.MAX_VALUE); 
	    	// Note : this will scroll to the bottom
	        // while Double.MIN_VALUE to scroll to the top
	    }
	});
	// textArea.setPadding(new Insets(2, 0, 2, 0));
	// textArea.setPrefWidth(560);
	textArea.setEditable(false);
	textArea.setWrapText(true);
	mainScene.setQuickToolTip(textArea, "Conversations on MarsNet");
	// ta.appendText("System : WARNING! A small dust storm 20 km away NNW may be
	// heading toward the Alpha Base" + System.lineSeparator());

	// Replaced textField with autoFillTextBox
	autoFillTextBox = new AutoFillTextBox<String>(autoCompleteData);
	autoFillTextBox.setPadding(new Insets(2, 0, 0, 0));
	autoFillTextBox.getStylesheets().addAll(AUTOFILL);
	autoFillTextBox.setStyle(
			// "-fx-background-color: white;"
			// + "-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.8), 10, 0, 0, 0);"
			// + "-fx-text-fill: white;"
			"-fx-background-radius: 5px;");

	autoFillTextBox.setFilterMode(false);
	autoFillTextBox.getTextbox().addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> {
		keyHandler(keyEvent);
	});

	autoFillTextBox.getTextbox().setMaxWidth(565);
	autoFillTextBox.getTextbox().setMinWidth(565);
	autoFillTextBox.getTextbox().setPrefWidth(565);
	// autoFillTextBox.setStyle("-fx-font: 11pt 'Corbel';");
	// autoFillTextBox.setTooltip(new Tooltip ("Use UP/DOWN arrows to scroll
	// history"));
	mainScene.setQuickToolTip(autoFillTextBox, "Use UP/DOWN arrows to scroll history");
	autoFillTextBox.getTextbox().setPromptText("Type your msg here");// to broadcast to a channel");

	broadcastButton = new JFXButton(" Broadcast ".toUpperCase());
	broadcastButton.getStyleClass().clear();
	broadcastButton.getStyleClass().add("button-broadcast");
	// broadcastButton.setTooltip(new Tooltip ("Click or press Enter to send msg"));
	mainScene.setQuickToolTip(broadcastButton, "Click or press Enter to send msg");
	broadcastButton.setOnAction(e -> {
		String text = autoFillTextBox.getTextbox().getText();
		if (text != "" && text != null && !text.trim().isEmpty()) {
			hitEnter();
		} else {
			autoFillTextBox.getTextbox().clear();
		}
	});

	HBox hbox = new HBox();
	hbox.setSpacing(1);
	hbox.setPadding(new Insets(0, 0, 0, 0));
	hbox.getChildren().addAll(broadcastButton, autoFillTextBox);// .getTextbox());

	titleLabel = new Label("  " + Msg.getString("ChatBox.title")); //$NON-NLS-1$

	setCenter(textArea);
	setBottom(hbox);
}
 
Example 13
Source File: ServiceEditFoundLuggageViewController.java    From Corendon-LostLuggage with MIT License 4 votes vote down vote up
/**  
 * Here will the luggage be updated 
 * 
 *      update the luggage and switch the view 
 * 
 * @param changedFields
 * @param changes
 * @void no direct output, only a alert dialog 
 */
public void alertDialog(String changedFields, int changes){
    //Remove the first , (comma) and space
    changedFields = changedFields.substring(2);
    
    //Clear the previous message
    CONTENT.getHeading().clear();
    ALERT_MESSAGE.getChildren().clear();
    
    //Set heading of dialog
    CONTENT.setHeading(new Text("Warning"));
    
    //Set the right text for the dialog body.
    String introAlert,outroAlert;
    if (changes == 1){                                      //singular
        introAlert = "There is "+changes+" change made. \n"
            + "The changed field is the following: \n\n";
        outroAlert = "\n\nPlease check and confirm it.";
    } else {                                                //plural
        introAlert = "There are "+changes+" changes made. \n"
            + "The changed fields are the following: \n\n";
        outroAlert = "\n\nPlease check and confirm them.";
    }
    
    Text intro = new Text(introAlert);
    Text changed = new Text(changedFields);
    Text outro = new Text(outroAlert);
    
    //set text color of changed field string to red
    changed.setFill(Color.web(ALERT_COLOR));  
    
    //combine the text parts
    ALERT_MESSAGE.getChildren().addAll(intro, changed, outro);
    //set the text parts (alert message) in the content
    CONTENT.setBody(ALERT_MESSAGE);
    
    //create the dialog alert with the content
    //& place het in the center of the stackpane
    JFXDialog alert = new JFXDialog(stackPane, CONTENT, JFXDialog.DialogTransition.CENTER);
    
    //Create the 'ok'/close button
    JFXButton button = new JFXButton("ok");
    //set button action listner for closing the alert
    button.setOnAction((ActionEvent event) -> {
        alert.close();
        //hide the stackpane so the fields will be clickable again
        closeStackpane();
    });
    //set action button in content for alert
    CONTENT.setActions(button);
    
    //Show the alert message (dialog)
    alert.show();
    //show the stackpane so the dialog will be visible 
    stackPane.setVisible(true);
    
    //change the text on the 'save changes'  button
    saveEditings.setText("Confirm Changes");
}
 
Example 14
Source File: AdminAddUserViewController.java    From Corendon-LostLuggage with MIT License 4 votes vote down vote up
@FXML
private void showPasswordResetMessage(ActionEvent event) throws IOException {
    stackPane.setVisible(true);
    MESSAGE_FLOW.getChildren().clear();
    userId = employeeIdField.getText();

    //Customize header
    Text header = new Text("Note: This action can't be undone");
    header.setFont(new Font("System", 18));
    header.setFill(Paint.valueOf("#495057"));

    JFXButton cancelButton = new JFXButton("Cancel");
    JFXButton resetButton = new JFXButton("Reset");

    //Customize buttons
    cancelButton.setStyle("-fx-background-color: #adb5bd");
    cancelButton.setTextFill(Paint.valueOf("#FFFFFF"));
    cancelButton.setRipplerFill(Paint.valueOf("#FFFFFF"));
    cancelButton.setButtonType(JFXButton.ButtonType.RAISED);

    resetButton.setStyle("-fx-background-color: #4dadf7");
    resetButton.setTextFill(Paint.valueOf("#FFFFFF"));
    resetButton.setRipplerFill(Paint.valueOf("#FFFFFF"));
    resetButton.setButtonType(JFXButton.ButtonType.RAISED);

    MESSAGE_FLOW.getChildren().add(new Text("Are you sure you want to reset the password of user: " + userId));
    DIALOG_LAYOUT.setHeading(header);
    DIALOG_LAYOUT.setBody(MESSAGE_FLOW);
    DIALOG_LAYOUT.setActions(cancelButton, resetButton);
    //DIALOG_LAYOUT.setActions(resetButton);

    alertView = new JFXDialog(stackPane, DIALOG_LAYOUT, JFXDialog.DialogTransition.CENTER);
    alertView.setOverlayClose(false);
    cancelButton.setOnAction(e -> {
        alertView.close();
        stackPane.setVisible(false);
    });

    resetButton.setOnAction(e -> {
        System.out.println("The password has been reset");
        //alertView.close();
        try {
            resetPassword();
        } catch (SQLException ex) {
            Logger.getLogger(AdminAddUserViewController.class.getName()).log(Level.SEVERE, null, ex);
        }

    });

    alertView.show();
}
 
Example 15
Source File: ServiceEditLostLuggageViewController.java    From Corendon-LostLuggage with MIT License 4 votes vote down vote up
/**  
 * Here will the luggage be updated 
 * 
 *      update the luggage and switch the view 
 * 
 * @param changedFields
 * @param changes
 * @void no direct output, only a alert dialog 
 */
public void alertDialog(String changedFields, int changes){
    //Remove the first , (comma) and space
    changedFields = changedFields.substring(2);
    
    //Clear the previous message
    CONTENT.getHeading().clear();
    ALERT_MESSAGE.getChildren().clear();
    
    //Set heading of dialog
    CONTENT.setHeading(new Text("Warning"));
    
    //Set the right text for the dialog body.
    String introAlert,outroAlert;
    if (changes == 1){                                      //singular
        introAlert = "There is "+changes+" change made. \n"
            + "The changed field is the following: \n\n";
        outroAlert = "\n\nPlease check and confirm it.";
    } else {                                                //plural
        introAlert = "There are "+changes+" changes made. \n"
            + "The changed fields are the following: \n\n";
        outroAlert = "\n\nPlease check and confirm them.";
    }
    
    Text intro = new Text(introAlert);
    Text changed = new Text(changedFields);
    Text outro = new Text(outroAlert);
    
    //set text color of changed field string to red
    changed.setFill(Color.web(ALERT_COLOR));  
    
    //combine the text parts
    ALERT_MESSAGE.getChildren().addAll(intro, changed, outro);
    //set the text parts (alert message) in the content
    CONTENT.setBody(ALERT_MESSAGE);
    
    //create the dialog alert with the content
    //& place het in the center of the stackpane
    JFXDialog alert = new JFXDialog(stackPane, CONTENT, JFXDialog.DialogTransition.CENTER);
    
    //Create the 'ok'/close button
    JFXButton button = new JFXButton("ok");
    button.setOnAction((ActionEvent event) -> {
        alert.close();
        //hide the stackpane so the fields will be clickable again
        closeStackpane();
    });
    //set action button in content for alert
    CONTENT.setActions(button);
    
    //Show the alert message (dialog)
    alert.show();
    //show the stackpane so the dialog will be visible 
    stackPane.setVisible(true);
    
    //change the text on the 'save changes'  button
    saveEditings.setText("Confirm Changes");
}
 
Example 16
Source File: FindReplaceDialog.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new find and replace dialog.
 *
 * @param controller editor controller
 */
public FindReplaceDialog(Editor controller) {
  super();
  //
  this.controller = controller;
  // found indexes
  found = new ArrayList<Integer>();
  // create anchor pane
  setMinHeight(130);
  setMaxHeight(130);
  setPrefHeight(130);
  getStyleClass().add("findreplace-anchor-pane");
  // create horizontal box
  HBox box = new HBox();
  box.setAlignment(Pos.CENTER);
  box.setSpacing(5.0);
  setRightAnchor(box, 5.0);
  setTopAnchor(box, 5.0);
  // create buttons
  JFXButton find = new JFXButton("Find");
  find.getStyleClass().add("findreplace");
  JFXButton replace = new JFXButton("Replace");
  replace.getStyleClass().add("findreplace");
  JFXButton replaceAll = new JFXButton("Replace All");
  replaceAll.getStyleClass().add("findreplace");
  JFXButton close = new JFXButton("x");
  close.getStyleClass().add("close");
  caseSensitive = new JFXCheckBox("Aa");
  caseSensitive.getStyleClass().add("findreplace");
  box.getChildren().addAll(find, replaceAll, caseSensitive, close);
  // create label
  label = new Label("Find And Replace");
  label.getStyleClass().add("findreplace");
  setLeftAnchor(label, 5.0);
  setTopAnchor(label, 5.0);
  // create text fields
  findText = new JFXTextField();
  findText.setPromptText("Find in current buffer");
  findText.getStyleClass().add("findreplace");
  setRightAnchor(findText, 10.0);
  setLeftAnchor(findText, 10.0);
  setTopAnchor(findText, 45.0);
  replaceText = new JFXTextField();
  replaceText.setPromptText("Replace in current buffer");
  replaceText.getStyleClass().add("findreplace");
  setRightAnchor(replaceText, 10.0);
  setLeftAnchor(replaceText, 10.0);
  setTopAnchor(replaceText, 90.0);
  getChildren().addAll(label, findText, replaceText, box);
  // bindings
  find.setOnAction(e -> find());
  replace.setOnAction(e -> replace());
  replaceAll.setOnAction(e -> replaceAll());
  close.setOnAction(e -> controller.removeFindReplaceDialog());
  // perform a search if find text field change
  findText.textProperty().addListener((e, o, n) -> search());
  // perform a search if case sensitive checkbox selected property changes
  caseSensitive.selectedProperty().addListener((e, o, n) -> search());
  // perform a search if the current tab changes
  controller.getEditorTabPane().getSelectionModel().selectedItemProperty().addListener((e, o, n) -> search());
}
 
Example 17
Source File: FxmlBuilder.java    From milkman with MIT License 4 votes vote down vote up
public static JFXButton submit(Runnable action, String text){
	JFXButton apply = new JFXButton(text);
	apply.setDefaultButton(true);
	apply.setOnAction(e -> action.run());
	return apply;
}
 
Example 18
Source File: FxmlBuilder.java    From milkman with MIT License 4 votes vote down vote up
public static JFXButton button(Node graphic, Runnable onAction) {
	JFXButton jfxButton = new JFXButton();
	jfxButton.setGraphic(graphic);
	jfxButton.setOnAction(e -> onAction.run());
	return jfxButton;
}
 
Example 19
Source File: BrowserJFX.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void createTopButtonBar() {
 	
 	String shortcutsURL = getClass().getResource(Msg.getString("doc.shortcuts")).toExternalForm(); //$NON-NLS-1$
 	String guideURL = getClass().getResource(Msg.getString("doc.guide")).toExternalForm(); //$NON-NLS-1$
 	String aboutURL = getClass().getResource(Msg.getString("doc.about")).toExternalForm(); //$NON-NLS-1$
 	String tutorialURL = getClass().getResource(Msg.getString("doc.tutorial")).toExternalForm(); //$NON-NLS-1$
 	String projectsiteURL = Msg.getString("url.projectSite"); //$NON-NLS-1$
 	String wikiURL = Msg.getString("url.wiki"); //$NON-NLS-1$
 	String marspediaURL = Msg.getString("url.marspedia"); //$NON-NLS-1$
		
 	JFXButton b0 = new JFXButton(Msg.getString("GuideWindow.button.about")); //$NON-NLS-1$
 	b0.setPadding(new Insets(5,25,5,25));
 	b0.setMinWidth(WIDTH+5);
 	b0.setTooltip(new Tooltip("About mars-sim"));
 	b0.setOnAction(e -> {
 		fireURL(aboutURL);
     });

 	JFXButton b1 = new JFXButton(Msg.getString("GuideWindow.button.tutorial")); //$NON-NLS-1$
 	b1.setPadding(new Insets(5,25,5,25));
 	b1.setMinWidth(WIDTH+5);
 	b1.setTooltip(new Tooltip("Tutorial"));
 	b1.setOnAction(e -> {
 		fireURL(tutorialURL);
     });
 	
 	JFXButton b2 = new JFXButton(Msg.getString("GuideWindow.button.userguide")); //$NON-NLS-1$
 	b2.setPadding(new Insets(5,25,5,25));
 	b2.setMinWidth(WIDTH+5);
 	b2.setTooltip(new Tooltip("User Guide"));
 	b2.setOnAction(e -> {
 		fireURL(guideURL);
     });
 	
 	JFXButton b3 = new JFXButton(Msg.getString("GuideWindow.button.shortcuts")); //$NON-NLS-1$
 	b3.setPadding(new Insets(5,25,5,25));
 	b3.setMinWidth(WIDTH+5);
 	b3.setTooltip(new Tooltip("Shortcut Map"));
 	b3.setOnAction(e -> {
 		fireURL(shortcutsURL);
     });
 	
 	JFXButton b4 = new JFXButton(Msg.getString("GuideWindow.button.projectsite")); //$NON-NLS-1$
 	b4.setPadding(new Insets(5,25,5,25));
 	b4.setMinWidth(WIDTH+5);
 	b4.setTooltip(new Tooltip("Project Site in GitHub"));
 	b4.setOnAction(e -> {
 		fireURL(projectsiteURL);
     });
 	
 	JFXButton b5 = new JFXButton(Msg.getString("GuideWindow.button.wiki")); //$NON-NLS-1$
 	b5.setPadding(new Insets(5,25,5,25));
 	b5.setMinWidth(WIDTH+5);
 	b5.setTooltip(new Tooltip("mars-sim Wiki"));
 	b5.setOnAction(e -> {
fireURL(wikiURL);
     });
 
 	JFXButton b6 = new JFXButton(Msg.getString("GuideWindow.button.marspedia")); //$NON-NLS-1$
 	b6.setPadding(new Insets(5,25,5,25));
 	b6.setMinWidth(WIDTH+5);
 	b6.setTooltip(new Tooltip("A Random Page from Marspedia"));
 	b6.setOnAction(e -> {
fireURL(marspediaURL);
     });
 	    	
 	topButtonBar.setPadding(new Insets(5,5,5,5));
 	topButtonBar.getChildren().addAll(b0, b1, b2, b3, b4, b5, b6);
 }
 
Example 20
Source File: FxmlBuilder.java    From milkman with MIT License 4 votes vote down vote up
public static JFXButton button(String text, Runnable onAction) {
	JFXButton jfxButton = new JFXButton(text);
	jfxButton.setOnAction(e -> onAction.run());
	return jfxButton;
}