Java examples for JavaFX:Dialog
create JavaFX Information Dialog
import javafx.scene.control.Alert; import javafx.scene.control.Label; import javafx.scene.control.TextArea; import javafx.scene.layout.GridPane; import javafx.scene.layout.Priority; import java.io.PrintWriter; import java.io.StringWriter; public class Main{ public static final Alert createInformationDialog( Alert.AlertType alertType, String headerText, String info) { Alert alert = new Alert(alertType); Label label = new Label(headerText); TextArea textArea = new TextArea(info); textArea.setEditable(false);/*from ww w .ja va2s . c o m*/ textArea.setWrapText(true); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(textArea, Priority.ALWAYS); GridPane.setHgrow(textArea, Priority.ALWAYS); GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(label, 0, 0); expContent.add(textArea, 0, 1); alert.getDialogPane().setExpandableContent(expContent); alert.getDialogPane().setExpanded(true); return alert; } }