1) Base form:
import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.ButtonType; ... Alert alert = new Alert( AlertType.INFORMATION, "This is alert." ); alert.showAndWait();
2) You can specify button (or more buttons):
alert = new Alert( AlertType.INFORMATION, "This is alert.\n\nSecond line.", new ButtonType( "Close it" ) ); alert.showAndWait();
3) Or you can specify dialog title and remove header text:
Alert alert = new Alert( AlertType.INFORMATION ); alert.setTitle( "Info" ); alert.setHeaderText( null ); alert.setContentText( "This is alert.\n\nSecond line." ); alert.showAndWait();
No comments:
Post a Comment