Java Code Examples for javafx.scene.layout.Pane#lookup()

The following examples show how to use javafx.scene.layout.Pane#lookup() . 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: FxmlControl.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static Node findNode(Pane pane, String nodeId) {
    try {
        Node node = pane.lookup("#" + nodeId);
        return node;
    } catch (Exception e) {
        return null;
    }
}
 
Example 2
Source File: FxmlControl.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static boolean setStyle(Pane pane, String nodeId, String style) {
    try {
        Node node = pane.lookup("#" + nodeId);
        return setStyle(node, style);
    } catch (Exception e) {
        return false;
    }
}
 
Example 3
Source File: Gui.java    From ARMStrong with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * display a warning popup
 * @param message the message to display
 * @param okEvent an event fired when the user presses the ok button
 */
public static void warningPopup(String message, EventHandler<ActionEvent> okEvent) {
	final Stage warningStage = new Stage();
	warningStage.setTitle("Warning");

	warningStage.initModality(Modality.APPLICATION_MODAL);
	warningStage.setResizable(false);

	try {
		Pane main = FXMLLoader.load(Gui.class.getResource("/resources/warning.fxml"));
		warningStage.setScene(new Scene(main, 500, 280));

		Text messageText = (Text) main.lookup("#message");
		messageText.setText(message);

		ImageView image = (ImageView) main.lookup("#image");
		image.setImage(new Image(Gui.class.getResource("/resources/warning.png").toExternalForm()));

		Button okButton = (Button) main.lookup("#ok");
		Button cancelButton = (Button) main.lookup("#cancel");
		okButton.setOnAction(okEvent);
		okButton.setOnMouseReleased(mouseEvent -> warningStage.close());
		okButton.setOnKeyPressed(keyEvent -> warningStage.close());

		cancelButton.setOnAction(actionEvent1 -> warningStage.close());

	} catch (IOException e) {
		e.printStackTrace();
	}
	warningStage.show();
}