How to create and show common dialog (Error, Warning, Confirmation) in JavaFX 2.0?
How do I create and show common dialogs (Error, Warning, Confirmation) in JavaFX 2.0? I can't find any "standard" classes like Dialog
, DialogBox
, Message
or something.
dialog javafx-2
add a comment |
How do I create and show common dialogs (Error, Warning, Confirmation) in JavaFX 2.0? I can't find any "standard" classes like Dialog
, DialogBox
, Message
or something.
dialog javafx-2
Perhaps you like to have a look on project for private use: github.com/4ntoine/JavaFxDialog/wiki
– BudMinton
Sep 5 '12 at 13:55
Backport of JavaFX 8 dialogs to JDK7: github.com/BertelSpA/openjfx-dialogs-jdk7
– Paolo Fulgoni
Jun 16 '15 at 9:00
add a comment |
How do I create and show common dialogs (Error, Warning, Confirmation) in JavaFX 2.0? I can't find any "standard" classes like Dialog
, DialogBox
, Message
or something.
dialog javafx-2
How do I create and show common dialogs (Error, Warning, Confirmation) in JavaFX 2.0? I can't find any "standard" classes like Dialog
, DialogBox
, Message
or something.
dialog javafx-2
dialog javafx-2
edited Nov 29 '11 at 15:03
Kevin
39.5k1079114
39.5k1079114
asked Nov 29 '11 at 11:28
AntonAnton
80331118
80331118
Perhaps you like to have a look on project for private use: github.com/4ntoine/JavaFxDialog/wiki
– BudMinton
Sep 5 '12 at 13:55
Backport of JavaFX 8 dialogs to JDK7: github.com/BertelSpA/openjfx-dialogs-jdk7
– Paolo Fulgoni
Jun 16 '15 at 9:00
add a comment |
Perhaps you like to have a look on project for private use: github.com/4ntoine/JavaFxDialog/wiki
– BudMinton
Sep 5 '12 at 13:55
Backport of JavaFX 8 dialogs to JDK7: github.com/BertelSpA/openjfx-dialogs-jdk7
– Paolo Fulgoni
Jun 16 '15 at 9:00
Perhaps you like to have a look on project for private use: github.com/4ntoine/JavaFxDialog/wiki
– BudMinton
Sep 5 '12 at 13:55
Perhaps you like to have a look on project for private use: github.com/4ntoine/JavaFxDialog/wiki
– BudMinton
Sep 5 '12 at 13:55
Backport of JavaFX 8 dialogs to JDK7: github.com/BertelSpA/openjfx-dialogs-jdk7
– Paolo Fulgoni
Jun 16 '15 at 9:00
Backport of JavaFX 8 dialogs to JDK7: github.com/BertelSpA/openjfx-dialogs-jdk7
– Paolo Fulgoni
Jun 16 '15 at 9:00
add a comment |
9 Answers
9
active
oldest
votes
Recently released JDK 1.8.0_40 added support for JavaFX dialogs, alerts, etc. For example, to show a confirmation dialog, one would use the Alert class:
Alert alert = new Alert(AlertType.CONFIRMATION, "Delete " + selection + " ?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {
//do stuff
}
Here's a list of added classes in this release:
- javafx.scene.control.Dialog
- javafx.scene.control.Alert
- javafx.scene.control.TextInputDialog
- javafx.scene.control.ChoiceDialog
Found this to be a good solution, I didn't find a way to title the top of the dialogue but not a big deal. But then again, would you need too...? Cheers
– Gideon Sassoon
Mar 21 '16 at 19:21
@GideonSassoon The alert object can be modified after creation. A call to alert.setTitle() before showAndWait() should do nicely.
– Ali Cheaito
Mar 21 '16 at 20:25
Excelente solution without including external libs
– JorgeGarza
Mar 24 '17 at 18:59
@GideonSassoon You can set the header text withalert.setHeaderText("header text");
if that is what you need
– nonybrighto
Apr 13 '17 at 14:38
SImple et précis ! Merci ^^
– Mangue Sutcliff
Nov 28 '18 at 14:50
add a comment |
EDIT: dialog support was added to JavaFX, see https://stackoverflow.com/a/28887273/1054140
There were no common dialog support in a year 2011.
You had to write it yourself by creating new Stage()
:
Stage dialogStage = new Stage();
dialogStage.initModality(Modality.WINDOW_MODAL);
VBox vbox = new VBox(new Text("Hi"), new Button("Ok."));
vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(15));
dialogStage.setScene(new Scene(vbox));
dialogStage.show();
11
Hmm, may be, they will appear later like FileChooser? Or they wish every developer to reinvent the wheel?)
– Anton
Dec 1 '11 at 9:49
1
You may want to file RFE for that matter at javafx-jira.kenai.com
– Sergey Grinev
Dec 1 '11 at 16:48
9
Ready standard dialogs project for JavaFX 2.0. Works for me
– Anton
Dec 9 '11 at 8:12
2
Official platform support for Alert dialog can be tracked via javafx-jira.kenai.com/browse/RT-12643
– jewelsea
Aug 25 '12 at 8:40
3
VBoxBuilder is deprecated now. This is still a useful answer though it could do with a small update.
– Adam Jensen
Sep 9 '14 at 8:44
|
show 5 more comments
Update
Official standard dialogs are coming to JavaFX in release 8u40, as part of the implemenation of RT-12643. These should be available in final release form around March of 2015 and in source code form in the JavaFX development repository now.
In the meantime, you can use the ControlsFX solution below...
ControlsFX is the defacto standard 3rd party library for common dialog support in JavaFX (error, warning, confirmation, etc).
There are numerous other 3rd party libraries available which provide common dialog support as pointed out in some other answers and you can create your own dialogs easily enough using the sample code in Sergey's answer.
However, I believe that ControlsFX easily provide the best quality standard JavaFX dialogs available at the moment. Here are some samples from the ControlsFX documentation.
1
Voted up, but documentation links aren't apparent on the site linked. Also site says maven 8.0.2 is up, but for me only works with maven 8.0.1.. and I get an "Unsupported major.minor version 52.0" when calling Dialogs.create().message("great").showConfirm();
– Daniel Gerson
Aug 27 '13 at 9:50
2
Documentation links work fine for me. The documentation currently states "Important note: ControlsFX will only work on JavaFX 8.0 b102 or later." Likely you are trying to run ControlsFX against an incompatible Java version. If you have further issues you should log them against the ControlsFX issue tracker.
– jewelsea
Aug 27 '13 at 15:29
6
This only works with javafx8, not javafx2.
– John K
Oct 18 '13 at 23:52
ControlsFX looks great, thanks!
– Tim Büthe
Aug 6 '14 at 14:18
Good luck finding the documentation for this library.
– ojonugwa ochalifu
Jul 21 '17 at 9:46
add a comment |
Sergey is correct, but if you need to get a response from your home-spun dialog(s) for evaluation in the same block of code that invoked it, you should use .showAndWait(), not .show(). Here's my rendition of a couple of the dialog types that are provided in Swing's OptionPane:
public class FXOptionPane {
public enum Response { NO, YES, CANCEL };
private static Response buttonSelected = Response.CANCEL;
private static ImageView icon = new ImageView();
static class Dialog extends Stage {
public Dialog( String title, Stage owner, Scene scene, String iconFile ) {
setTitle( title );
initStyle( StageStyle.UTILITY );
initModality( Modality.APPLICATION_MODAL );
initOwner( owner );
setResizable( false );
setScene( scene );
icon.setImage( new Image( getClass().getResourceAsStream( iconFile ) ) );
}
public void showDialog() {
sizeToScene();
centerOnScreen();
showAndWait();
}
}
static class Message extends Text {
public Message( String msg ) {
super( msg );
setWrappingWidth( 250 );
}
}
public static Response showConfirmDialog( Stage owner, String message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Confirm.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button yesButton = new Button( "Yes" );
yesButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.YES;
}
} );
Button noButton = new Button( "No" );
noButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.NO;
}
} );
BorderPane bp = new BorderPane();
HBox buttons = new HBox();
buttons.setAlignment( Pos.CENTER );
buttons.setSpacing( 10 );
buttons.getChildren().addAll( yesButton, noButton );
bp.setCenter( buttons );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, new Message( message ) );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
return buttonSelected;
}
public static void showMessageDialog( Stage owner, String message, String title ) {
showMessageDialog( owner, new Message( message ), title );
}
public static void showMessageDialog( Stage owner, Node message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Info.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button okButton = new Button( "OK" );
okButton.setAlignment( Pos.CENTER );
okButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
}
} );
BorderPane bp = new BorderPane();
bp.setCenter( okButton );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, message );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
}
}
1
Was trying to run your class but the compiler chokes on Layout - apparently the constants used. Which import did you use?
– likejudo
Jan 15 '13 at 4:40
How does one get the response i.e. which button was selected? the member variable buttonSelected is private.
– likejudo
Jan 15 '13 at 5:16
got it to compile and made buttonSelected public but calling it like this does not display anything. ` Stage stage = new Stage(StageStyle.TRANSPARENT); FXOptionPane.showConfirmDialog(stage, "Do you wish to disconnect?", "my title"); `
– likejudo
Jan 15 '13 at 5:28
add a comment |
Adapted from answer here: https://stackoverflow.com/a/7505528/921224
javafx.scene.control.Alert
For a an in depth description of how to use JavaFX dialogs see: JavaFX Dialogs (official) by code.makery. They are much more powerful and flexible than Swing dialogs and capable of far more than just popping up messages.
import javafx.scene.control.Alert
import javafx.scene.control.Alert.AlertType;
import javafx.application.Platform;
public class ClassNameHere
{
public static void infoBox(String infoMessage, String titleBar)
{
/* By specifying a null headerMessage String, we cause the dialog to
not have a header */
infoBox(infoMessage, titleBar, null);
}
public static void infoBox(String infoMessage, String titleBar, String headerMessage)
{
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(titleBar);
alert.setHeaderText(headerMessage);
alert.setContentText(infoMessage);
alert.showAndWait();
}
}
One thing to keep in mind is that JavaFX is a single threaded GUI toolkit, which means this method should be called directly from the JavaFX application thread. If you have another thread doing work, which needs a dialog then see these SO Q&As: JavaFX2: Can I pause a background Task / Service? and Platform.Runlater and Task Javafx.
To use this method call:
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE");
or
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE", "HEADER MESSAGE");
Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question.
– Martijn Pieters♦
Jun 10 '15 at 14:54
1
@MartijnPieters The original question specifies Swing as a tag but is open to general Java dialogs (it was asked before JavaFX was really a thing), if anything the JavaFX content I posted there is slightly off topic, yet useful to newbies who find that Q&A while looking for Java Dialogs and don't realise that Swing is going out of date.
– Troyseph
Jun 10 '15 at 15:26
All the more reason then to tailor your answer to the context then!
– Martijn Pieters♦
Jun 10 '15 at 15:51
I found this topic on google, so it's better to have information right here than to enter question topic to see the answer i need. This answer deserves more votes.
– Mateus Viccari
Sep 16 '15 at 13:32
add a comment |
- You can have a look to the great tool JavaFX Dialogs are simple dialogs in the style of JOptionPane from Swing
add a comment |
You can give dialog box which given by the JavaFX UI Controls Project. I think it will help you
Dialogs.showErrorDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
Dialogs.showWarningDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
1
There are no such dialog classes in JavaFX 2.x
– jewelsea
Jul 17 '13 at 7:26
javafx-dialogs-0.0.3.jar You can download this jar and then you can work with the same dialog box.
– Rajeev Gupta
Jul 24 '13 at 7:10
I edited your post to link to the 3rd party JavaFX dialogs project Rajeev referenced. I think it is an older version of the dialogs from ControlsFX.
– jewelsea
Jul 24 '13 at 7:44
Yes , but its working fine.
– Rajeev Gupta
Jul 24 '13 at 9:42
add a comment |
public myClass{
private Stage dialogStage;
public void msgBox(String title){
dialogStage = new Stage();
GridPane grd_pan = new GridPane();
grd_pan.setAlignment(Pos.CENTER);
grd_pan.setHgap(10);
grd_pan.setVgap(10);//pading
Scene scene =new Scene(grd_pan,300,150);
dialogStage.setScene(scene);
dialogStage.setTitle("alert");
dialogStage.initModality(Modality.WINDOW_MODAL);
Label lab_alert= new Label(title);
grd_pan.add(lab_alert, 0, 1);
Button btn_ok = new Button("fermer");
btn_ok.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
// TODO Auto-generated method stub
dialogStage.hide();
}
});
grd_pan.add(btn_ok, 0, 2);
dialogStage.show();
}
}
2
It's probably a good idea to at least explain what your code is doing; there's fairly strong opinions on whether or not code-only answers are okay.
– Dennis Meng
May 30 '14 at 22:13
add a comment |
This working since java 8u40:
Alert alert = new Alert(AlertType.INFORMATION, "Content here", ButtonType.OK)
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE)
alert.show()
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8309981%2fhow-to-create-and-show-common-dialog-error-warning-confirmation-in-javafx-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
Recently released JDK 1.8.0_40 added support for JavaFX dialogs, alerts, etc. For example, to show a confirmation dialog, one would use the Alert class:
Alert alert = new Alert(AlertType.CONFIRMATION, "Delete " + selection + " ?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {
//do stuff
}
Here's a list of added classes in this release:
- javafx.scene.control.Dialog
- javafx.scene.control.Alert
- javafx.scene.control.TextInputDialog
- javafx.scene.control.ChoiceDialog
Found this to be a good solution, I didn't find a way to title the top of the dialogue but not a big deal. But then again, would you need too...? Cheers
– Gideon Sassoon
Mar 21 '16 at 19:21
@GideonSassoon The alert object can be modified after creation. A call to alert.setTitle() before showAndWait() should do nicely.
– Ali Cheaito
Mar 21 '16 at 20:25
Excelente solution without including external libs
– JorgeGarza
Mar 24 '17 at 18:59
@GideonSassoon You can set the header text withalert.setHeaderText("header text");
if that is what you need
– nonybrighto
Apr 13 '17 at 14:38
SImple et précis ! Merci ^^
– Mangue Sutcliff
Nov 28 '18 at 14:50
add a comment |
Recently released JDK 1.8.0_40 added support for JavaFX dialogs, alerts, etc. For example, to show a confirmation dialog, one would use the Alert class:
Alert alert = new Alert(AlertType.CONFIRMATION, "Delete " + selection + " ?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {
//do stuff
}
Here's a list of added classes in this release:
- javafx.scene.control.Dialog
- javafx.scene.control.Alert
- javafx.scene.control.TextInputDialog
- javafx.scene.control.ChoiceDialog
Found this to be a good solution, I didn't find a way to title the top of the dialogue but not a big deal. But then again, would you need too...? Cheers
– Gideon Sassoon
Mar 21 '16 at 19:21
@GideonSassoon The alert object can be modified after creation. A call to alert.setTitle() before showAndWait() should do nicely.
– Ali Cheaito
Mar 21 '16 at 20:25
Excelente solution without including external libs
– JorgeGarza
Mar 24 '17 at 18:59
@GideonSassoon You can set the header text withalert.setHeaderText("header text");
if that is what you need
– nonybrighto
Apr 13 '17 at 14:38
SImple et précis ! Merci ^^
– Mangue Sutcliff
Nov 28 '18 at 14:50
add a comment |
Recently released JDK 1.8.0_40 added support for JavaFX dialogs, alerts, etc. For example, to show a confirmation dialog, one would use the Alert class:
Alert alert = new Alert(AlertType.CONFIRMATION, "Delete " + selection + " ?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {
//do stuff
}
Here's a list of added classes in this release:
- javafx.scene.control.Dialog
- javafx.scene.control.Alert
- javafx.scene.control.TextInputDialog
- javafx.scene.control.ChoiceDialog
Recently released JDK 1.8.0_40 added support for JavaFX dialogs, alerts, etc. For example, to show a confirmation dialog, one would use the Alert class:
Alert alert = new Alert(AlertType.CONFIRMATION, "Delete " + selection + " ?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {
//do stuff
}
Here's a list of added classes in this release:
- javafx.scene.control.Dialog
- javafx.scene.control.Alert
- javafx.scene.control.TextInputDialog
- javafx.scene.control.ChoiceDialog
edited Mar 5 '15 at 20:58
answered Mar 5 '15 at 20:38
Ali CheaitoAli Cheaito
2,51211628
2,51211628
Found this to be a good solution, I didn't find a way to title the top of the dialogue but not a big deal. But then again, would you need too...? Cheers
– Gideon Sassoon
Mar 21 '16 at 19:21
@GideonSassoon The alert object can be modified after creation. A call to alert.setTitle() before showAndWait() should do nicely.
– Ali Cheaito
Mar 21 '16 at 20:25
Excelente solution without including external libs
– JorgeGarza
Mar 24 '17 at 18:59
@GideonSassoon You can set the header text withalert.setHeaderText("header text");
if that is what you need
– nonybrighto
Apr 13 '17 at 14:38
SImple et précis ! Merci ^^
– Mangue Sutcliff
Nov 28 '18 at 14:50
add a comment |
Found this to be a good solution, I didn't find a way to title the top of the dialogue but not a big deal. But then again, would you need too...? Cheers
– Gideon Sassoon
Mar 21 '16 at 19:21
@GideonSassoon The alert object can be modified after creation. A call to alert.setTitle() before showAndWait() should do nicely.
– Ali Cheaito
Mar 21 '16 at 20:25
Excelente solution without including external libs
– JorgeGarza
Mar 24 '17 at 18:59
@GideonSassoon You can set the header text withalert.setHeaderText("header text");
if that is what you need
– nonybrighto
Apr 13 '17 at 14:38
SImple et précis ! Merci ^^
– Mangue Sutcliff
Nov 28 '18 at 14:50
Found this to be a good solution, I didn't find a way to title the top of the dialogue but not a big deal. But then again, would you need too...? Cheers
– Gideon Sassoon
Mar 21 '16 at 19:21
Found this to be a good solution, I didn't find a way to title the top of the dialogue but not a big deal. But then again, would you need too...? Cheers
– Gideon Sassoon
Mar 21 '16 at 19:21
@GideonSassoon The alert object can be modified after creation. A call to alert.setTitle() before showAndWait() should do nicely.
– Ali Cheaito
Mar 21 '16 at 20:25
@GideonSassoon The alert object can be modified after creation. A call to alert.setTitle() before showAndWait() should do nicely.
– Ali Cheaito
Mar 21 '16 at 20:25
Excelente solution without including external libs
– JorgeGarza
Mar 24 '17 at 18:59
Excelente solution without including external libs
– JorgeGarza
Mar 24 '17 at 18:59
@GideonSassoon You can set the header text with
alert.setHeaderText("header text");
if that is what you need– nonybrighto
Apr 13 '17 at 14:38
@GideonSassoon You can set the header text with
alert.setHeaderText("header text");
if that is what you need– nonybrighto
Apr 13 '17 at 14:38
SImple et précis ! Merci ^^
– Mangue Sutcliff
Nov 28 '18 at 14:50
SImple et précis ! Merci ^^
– Mangue Sutcliff
Nov 28 '18 at 14:50
add a comment |
EDIT: dialog support was added to JavaFX, see https://stackoverflow.com/a/28887273/1054140
There were no common dialog support in a year 2011.
You had to write it yourself by creating new Stage()
:
Stage dialogStage = new Stage();
dialogStage.initModality(Modality.WINDOW_MODAL);
VBox vbox = new VBox(new Text("Hi"), new Button("Ok."));
vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(15));
dialogStage.setScene(new Scene(vbox));
dialogStage.show();
11
Hmm, may be, they will appear later like FileChooser? Or they wish every developer to reinvent the wheel?)
– Anton
Dec 1 '11 at 9:49
1
You may want to file RFE for that matter at javafx-jira.kenai.com
– Sergey Grinev
Dec 1 '11 at 16:48
9
Ready standard dialogs project for JavaFX 2.0. Works for me
– Anton
Dec 9 '11 at 8:12
2
Official platform support for Alert dialog can be tracked via javafx-jira.kenai.com/browse/RT-12643
– jewelsea
Aug 25 '12 at 8:40
3
VBoxBuilder is deprecated now. This is still a useful answer though it could do with a small update.
– Adam Jensen
Sep 9 '14 at 8:44
|
show 5 more comments
EDIT: dialog support was added to JavaFX, see https://stackoverflow.com/a/28887273/1054140
There were no common dialog support in a year 2011.
You had to write it yourself by creating new Stage()
:
Stage dialogStage = new Stage();
dialogStage.initModality(Modality.WINDOW_MODAL);
VBox vbox = new VBox(new Text("Hi"), new Button("Ok."));
vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(15));
dialogStage.setScene(new Scene(vbox));
dialogStage.show();
11
Hmm, may be, they will appear later like FileChooser? Or they wish every developer to reinvent the wheel?)
– Anton
Dec 1 '11 at 9:49
1
You may want to file RFE for that matter at javafx-jira.kenai.com
– Sergey Grinev
Dec 1 '11 at 16:48
9
Ready standard dialogs project for JavaFX 2.0. Works for me
– Anton
Dec 9 '11 at 8:12
2
Official platform support for Alert dialog can be tracked via javafx-jira.kenai.com/browse/RT-12643
– jewelsea
Aug 25 '12 at 8:40
3
VBoxBuilder is deprecated now. This is still a useful answer though it could do with a small update.
– Adam Jensen
Sep 9 '14 at 8:44
|
show 5 more comments
EDIT: dialog support was added to JavaFX, see https://stackoverflow.com/a/28887273/1054140
There were no common dialog support in a year 2011.
You had to write it yourself by creating new Stage()
:
Stage dialogStage = new Stage();
dialogStage.initModality(Modality.WINDOW_MODAL);
VBox vbox = new VBox(new Text("Hi"), new Button("Ok."));
vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(15));
dialogStage.setScene(new Scene(vbox));
dialogStage.show();
EDIT: dialog support was added to JavaFX, see https://stackoverflow.com/a/28887273/1054140
There were no common dialog support in a year 2011.
You had to write it yourself by creating new Stage()
:
Stage dialogStage = new Stage();
dialogStage.initModality(Modality.WINDOW_MODAL);
VBox vbox = new VBox(new Text("Hi"), new Button("Ok."));
vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(15));
dialogStage.setScene(new Scene(vbox));
dialogStage.show();
edited Jan 3 at 19:50
Morteza Jalambadani
1,04211023
1,04211023
answered Nov 29 '11 at 12:09
Sergey GrinevSergey Grinev
29.2k5107122
29.2k5107122
11
Hmm, may be, they will appear later like FileChooser? Or they wish every developer to reinvent the wheel?)
– Anton
Dec 1 '11 at 9:49
1
You may want to file RFE for that matter at javafx-jira.kenai.com
– Sergey Grinev
Dec 1 '11 at 16:48
9
Ready standard dialogs project for JavaFX 2.0. Works for me
– Anton
Dec 9 '11 at 8:12
2
Official platform support for Alert dialog can be tracked via javafx-jira.kenai.com/browse/RT-12643
– jewelsea
Aug 25 '12 at 8:40
3
VBoxBuilder is deprecated now. This is still a useful answer though it could do with a small update.
– Adam Jensen
Sep 9 '14 at 8:44
|
show 5 more comments
11
Hmm, may be, they will appear later like FileChooser? Or they wish every developer to reinvent the wheel?)
– Anton
Dec 1 '11 at 9:49
1
You may want to file RFE for that matter at javafx-jira.kenai.com
– Sergey Grinev
Dec 1 '11 at 16:48
9
Ready standard dialogs project for JavaFX 2.0. Works for me
– Anton
Dec 9 '11 at 8:12
2
Official platform support for Alert dialog can be tracked via javafx-jira.kenai.com/browse/RT-12643
– jewelsea
Aug 25 '12 at 8:40
3
VBoxBuilder is deprecated now. This is still a useful answer though it could do with a small update.
– Adam Jensen
Sep 9 '14 at 8:44
11
11
Hmm, may be, they will appear later like FileChooser? Or they wish every developer to reinvent the wheel?)
– Anton
Dec 1 '11 at 9:49
Hmm, may be, they will appear later like FileChooser? Or they wish every developer to reinvent the wheel?)
– Anton
Dec 1 '11 at 9:49
1
1
You may want to file RFE for that matter at javafx-jira.kenai.com
– Sergey Grinev
Dec 1 '11 at 16:48
You may want to file RFE for that matter at javafx-jira.kenai.com
– Sergey Grinev
Dec 1 '11 at 16:48
9
9
Ready standard dialogs project for JavaFX 2.0. Works for me
– Anton
Dec 9 '11 at 8:12
Ready standard dialogs project for JavaFX 2.0. Works for me
– Anton
Dec 9 '11 at 8:12
2
2
Official platform support for Alert dialog can be tracked via javafx-jira.kenai.com/browse/RT-12643
– jewelsea
Aug 25 '12 at 8:40
Official platform support for Alert dialog can be tracked via javafx-jira.kenai.com/browse/RT-12643
– jewelsea
Aug 25 '12 at 8:40
3
3
VBoxBuilder is deprecated now. This is still a useful answer though it could do with a small update.
– Adam Jensen
Sep 9 '14 at 8:44
VBoxBuilder is deprecated now. This is still a useful answer though it could do with a small update.
– Adam Jensen
Sep 9 '14 at 8:44
|
show 5 more comments
Update
Official standard dialogs are coming to JavaFX in release 8u40, as part of the implemenation of RT-12643. These should be available in final release form around March of 2015 and in source code form in the JavaFX development repository now.
In the meantime, you can use the ControlsFX solution below...
ControlsFX is the defacto standard 3rd party library for common dialog support in JavaFX (error, warning, confirmation, etc).
There are numerous other 3rd party libraries available which provide common dialog support as pointed out in some other answers and you can create your own dialogs easily enough using the sample code in Sergey's answer.
However, I believe that ControlsFX easily provide the best quality standard JavaFX dialogs available at the moment. Here are some samples from the ControlsFX documentation.
1
Voted up, but documentation links aren't apparent on the site linked. Also site says maven 8.0.2 is up, but for me only works with maven 8.0.1.. and I get an "Unsupported major.minor version 52.0" when calling Dialogs.create().message("great").showConfirm();
– Daniel Gerson
Aug 27 '13 at 9:50
2
Documentation links work fine for me. The documentation currently states "Important note: ControlsFX will only work on JavaFX 8.0 b102 or later." Likely you are trying to run ControlsFX against an incompatible Java version. If you have further issues you should log them against the ControlsFX issue tracker.
– jewelsea
Aug 27 '13 at 15:29
6
This only works with javafx8, not javafx2.
– John K
Oct 18 '13 at 23:52
ControlsFX looks great, thanks!
– Tim Büthe
Aug 6 '14 at 14:18
Good luck finding the documentation for this library.
– ojonugwa ochalifu
Jul 21 '17 at 9:46
add a comment |
Update
Official standard dialogs are coming to JavaFX in release 8u40, as part of the implemenation of RT-12643. These should be available in final release form around March of 2015 and in source code form in the JavaFX development repository now.
In the meantime, you can use the ControlsFX solution below...
ControlsFX is the defacto standard 3rd party library for common dialog support in JavaFX (error, warning, confirmation, etc).
There are numerous other 3rd party libraries available which provide common dialog support as pointed out in some other answers and you can create your own dialogs easily enough using the sample code in Sergey's answer.
However, I believe that ControlsFX easily provide the best quality standard JavaFX dialogs available at the moment. Here are some samples from the ControlsFX documentation.
1
Voted up, but documentation links aren't apparent on the site linked. Also site says maven 8.0.2 is up, but for me only works with maven 8.0.1.. and I get an "Unsupported major.minor version 52.0" when calling Dialogs.create().message("great").showConfirm();
– Daniel Gerson
Aug 27 '13 at 9:50
2
Documentation links work fine for me. The documentation currently states "Important note: ControlsFX will only work on JavaFX 8.0 b102 or later." Likely you are trying to run ControlsFX against an incompatible Java version. If you have further issues you should log them against the ControlsFX issue tracker.
– jewelsea
Aug 27 '13 at 15:29
6
This only works with javafx8, not javafx2.
– John K
Oct 18 '13 at 23:52
ControlsFX looks great, thanks!
– Tim Büthe
Aug 6 '14 at 14:18
Good luck finding the documentation for this library.
– ojonugwa ochalifu
Jul 21 '17 at 9:46
add a comment |
Update
Official standard dialogs are coming to JavaFX in release 8u40, as part of the implemenation of RT-12643. These should be available in final release form around March of 2015 and in source code form in the JavaFX development repository now.
In the meantime, you can use the ControlsFX solution below...
ControlsFX is the defacto standard 3rd party library for common dialog support in JavaFX (error, warning, confirmation, etc).
There are numerous other 3rd party libraries available which provide common dialog support as pointed out in some other answers and you can create your own dialogs easily enough using the sample code in Sergey's answer.
However, I believe that ControlsFX easily provide the best quality standard JavaFX dialogs available at the moment. Here are some samples from the ControlsFX documentation.
Update
Official standard dialogs are coming to JavaFX in release 8u40, as part of the implemenation of RT-12643. These should be available in final release form around March of 2015 and in source code form in the JavaFX development repository now.
In the meantime, you can use the ControlsFX solution below...
ControlsFX is the defacto standard 3rd party library for common dialog support in JavaFX (error, warning, confirmation, etc).
There are numerous other 3rd party libraries available which provide common dialog support as pointed out in some other answers and you can create your own dialogs easily enough using the sample code in Sergey's answer.
However, I believe that ControlsFX easily provide the best quality standard JavaFX dialogs available at the moment. Here are some samples from the ControlsFX documentation.
edited Aug 18 '14 at 23:53
answered Jul 17 '13 at 7:34
jewelseajewelsea
112k8265318
112k8265318
1
Voted up, but documentation links aren't apparent on the site linked. Also site says maven 8.0.2 is up, but for me only works with maven 8.0.1.. and I get an "Unsupported major.minor version 52.0" when calling Dialogs.create().message("great").showConfirm();
– Daniel Gerson
Aug 27 '13 at 9:50
2
Documentation links work fine for me. The documentation currently states "Important note: ControlsFX will only work on JavaFX 8.0 b102 or later." Likely you are trying to run ControlsFX against an incompatible Java version. If you have further issues you should log them against the ControlsFX issue tracker.
– jewelsea
Aug 27 '13 at 15:29
6
This only works with javafx8, not javafx2.
– John K
Oct 18 '13 at 23:52
ControlsFX looks great, thanks!
– Tim Büthe
Aug 6 '14 at 14:18
Good luck finding the documentation for this library.
– ojonugwa ochalifu
Jul 21 '17 at 9:46
add a comment |
1
Voted up, but documentation links aren't apparent on the site linked. Also site says maven 8.0.2 is up, but for me only works with maven 8.0.1.. and I get an "Unsupported major.minor version 52.0" when calling Dialogs.create().message("great").showConfirm();
– Daniel Gerson
Aug 27 '13 at 9:50
2
Documentation links work fine for me. The documentation currently states "Important note: ControlsFX will only work on JavaFX 8.0 b102 or later." Likely you are trying to run ControlsFX against an incompatible Java version. If you have further issues you should log them against the ControlsFX issue tracker.
– jewelsea
Aug 27 '13 at 15:29
6
This only works with javafx8, not javafx2.
– John K
Oct 18 '13 at 23:52
ControlsFX looks great, thanks!
– Tim Büthe
Aug 6 '14 at 14:18
Good luck finding the documentation for this library.
– ojonugwa ochalifu
Jul 21 '17 at 9:46
1
1
Voted up, but documentation links aren't apparent on the site linked. Also site says maven 8.0.2 is up, but for me only works with maven 8.0.1.. and I get an "Unsupported major.minor version 52.0" when calling Dialogs.create().message("great").showConfirm();
– Daniel Gerson
Aug 27 '13 at 9:50
Voted up, but documentation links aren't apparent on the site linked. Also site says maven 8.0.2 is up, but for me only works with maven 8.0.1.. and I get an "Unsupported major.minor version 52.0" when calling Dialogs.create().message("great").showConfirm();
– Daniel Gerson
Aug 27 '13 at 9:50
2
2
Documentation links work fine for me. The documentation currently states "Important note: ControlsFX will only work on JavaFX 8.0 b102 or later." Likely you are trying to run ControlsFX against an incompatible Java version. If you have further issues you should log them against the ControlsFX issue tracker.
– jewelsea
Aug 27 '13 at 15:29
Documentation links work fine for me. The documentation currently states "Important note: ControlsFX will only work on JavaFX 8.0 b102 or later." Likely you are trying to run ControlsFX against an incompatible Java version. If you have further issues you should log them against the ControlsFX issue tracker.
– jewelsea
Aug 27 '13 at 15:29
6
6
This only works with javafx8, not javafx2.
– John K
Oct 18 '13 at 23:52
This only works with javafx8, not javafx2.
– John K
Oct 18 '13 at 23:52
ControlsFX looks great, thanks!
– Tim Büthe
Aug 6 '14 at 14:18
ControlsFX looks great, thanks!
– Tim Büthe
Aug 6 '14 at 14:18
Good luck finding the documentation for this library.
– ojonugwa ochalifu
Jul 21 '17 at 9:46
Good luck finding the documentation for this library.
– ojonugwa ochalifu
Jul 21 '17 at 9:46
add a comment |
Sergey is correct, but if you need to get a response from your home-spun dialog(s) for evaluation in the same block of code that invoked it, you should use .showAndWait(), not .show(). Here's my rendition of a couple of the dialog types that are provided in Swing's OptionPane:
public class FXOptionPane {
public enum Response { NO, YES, CANCEL };
private static Response buttonSelected = Response.CANCEL;
private static ImageView icon = new ImageView();
static class Dialog extends Stage {
public Dialog( String title, Stage owner, Scene scene, String iconFile ) {
setTitle( title );
initStyle( StageStyle.UTILITY );
initModality( Modality.APPLICATION_MODAL );
initOwner( owner );
setResizable( false );
setScene( scene );
icon.setImage( new Image( getClass().getResourceAsStream( iconFile ) ) );
}
public void showDialog() {
sizeToScene();
centerOnScreen();
showAndWait();
}
}
static class Message extends Text {
public Message( String msg ) {
super( msg );
setWrappingWidth( 250 );
}
}
public static Response showConfirmDialog( Stage owner, String message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Confirm.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button yesButton = new Button( "Yes" );
yesButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.YES;
}
} );
Button noButton = new Button( "No" );
noButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.NO;
}
} );
BorderPane bp = new BorderPane();
HBox buttons = new HBox();
buttons.setAlignment( Pos.CENTER );
buttons.setSpacing( 10 );
buttons.getChildren().addAll( yesButton, noButton );
bp.setCenter( buttons );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, new Message( message ) );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
return buttonSelected;
}
public static void showMessageDialog( Stage owner, String message, String title ) {
showMessageDialog( owner, new Message( message ), title );
}
public static void showMessageDialog( Stage owner, Node message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Info.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button okButton = new Button( "OK" );
okButton.setAlignment( Pos.CENTER );
okButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
}
} );
BorderPane bp = new BorderPane();
bp.setCenter( okButton );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, message );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
}
}
1
Was trying to run your class but the compiler chokes on Layout - apparently the constants used. Which import did you use?
– likejudo
Jan 15 '13 at 4:40
How does one get the response i.e. which button was selected? the member variable buttonSelected is private.
– likejudo
Jan 15 '13 at 5:16
got it to compile and made buttonSelected public but calling it like this does not display anything. ` Stage stage = new Stage(StageStyle.TRANSPARENT); FXOptionPane.showConfirmDialog(stage, "Do you wish to disconnect?", "my title"); `
– likejudo
Jan 15 '13 at 5:28
add a comment |
Sergey is correct, but if you need to get a response from your home-spun dialog(s) for evaluation in the same block of code that invoked it, you should use .showAndWait(), not .show(). Here's my rendition of a couple of the dialog types that are provided in Swing's OptionPane:
public class FXOptionPane {
public enum Response { NO, YES, CANCEL };
private static Response buttonSelected = Response.CANCEL;
private static ImageView icon = new ImageView();
static class Dialog extends Stage {
public Dialog( String title, Stage owner, Scene scene, String iconFile ) {
setTitle( title );
initStyle( StageStyle.UTILITY );
initModality( Modality.APPLICATION_MODAL );
initOwner( owner );
setResizable( false );
setScene( scene );
icon.setImage( new Image( getClass().getResourceAsStream( iconFile ) ) );
}
public void showDialog() {
sizeToScene();
centerOnScreen();
showAndWait();
}
}
static class Message extends Text {
public Message( String msg ) {
super( msg );
setWrappingWidth( 250 );
}
}
public static Response showConfirmDialog( Stage owner, String message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Confirm.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button yesButton = new Button( "Yes" );
yesButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.YES;
}
} );
Button noButton = new Button( "No" );
noButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.NO;
}
} );
BorderPane bp = new BorderPane();
HBox buttons = new HBox();
buttons.setAlignment( Pos.CENTER );
buttons.setSpacing( 10 );
buttons.getChildren().addAll( yesButton, noButton );
bp.setCenter( buttons );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, new Message( message ) );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
return buttonSelected;
}
public static void showMessageDialog( Stage owner, String message, String title ) {
showMessageDialog( owner, new Message( message ), title );
}
public static void showMessageDialog( Stage owner, Node message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Info.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button okButton = new Button( "OK" );
okButton.setAlignment( Pos.CENTER );
okButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
}
} );
BorderPane bp = new BorderPane();
bp.setCenter( okButton );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, message );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
}
}
1
Was trying to run your class but the compiler chokes on Layout - apparently the constants used. Which import did you use?
– likejudo
Jan 15 '13 at 4:40
How does one get the response i.e. which button was selected? the member variable buttonSelected is private.
– likejudo
Jan 15 '13 at 5:16
got it to compile and made buttonSelected public but calling it like this does not display anything. ` Stage stage = new Stage(StageStyle.TRANSPARENT); FXOptionPane.showConfirmDialog(stage, "Do you wish to disconnect?", "my title"); `
– likejudo
Jan 15 '13 at 5:28
add a comment |
Sergey is correct, but if you need to get a response from your home-spun dialog(s) for evaluation in the same block of code that invoked it, you should use .showAndWait(), not .show(). Here's my rendition of a couple of the dialog types that are provided in Swing's OptionPane:
public class FXOptionPane {
public enum Response { NO, YES, CANCEL };
private static Response buttonSelected = Response.CANCEL;
private static ImageView icon = new ImageView();
static class Dialog extends Stage {
public Dialog( String title, Stage owner, Scene scene, String iconFile ) {
setTitle( title );
initStyle( StageStyle.UTILITY );
initModality( Modality.APPLICATION_MODAL );
initOwner( owner );
setResizable( false );
setScene( scene );
icon.setImage( new Image( getClass().getResourceAsStream( iconFile ) ) );
}
public void showDialog() {
sizeToScene();
centerOnScreen();
showAndWait();
}
}
static class Message extends Text {
public Message( String msg ) {
super( msg );
setWrappingWidth( 250 );
}
}
public static Response showConfirmDialog( Stage owner, String message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Confirm.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button yesButton = new Button( "Yes" );
yesButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.YES;
}
} );
Button noButton = new Button( "No" );
noButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.NO;
}
} );
BorderPane bp = new BorderPane();
HBox buttons = new HBox();
buttons.setAlignment( Pos.CENTER );
buttons.setSpacing( 10 );
buttons.getChildren().addAll( yesButton, noButton );
bp.setCenter( buttons );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, new Message( message ) );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
return buttonSelected;
}
public static void showMessageDialog( Stage owner, String message, String title ) {
showMessageDialog( owner, new Message( message ), title );
}
public static void showMessageDialog( Stage owner, Node message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Info.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button okButton = new Button( "OK" );
okButton.setAlignment( Pos.CENTER );
okButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
}
} );
BorderPane bp = new BorderPane();
bp.setCenter( okButton );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, message );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
}
}
Sergey is correct, but if you need to get a response from your home-spun dialog(s) for evaluation in the same block of code that invoked it, you should use .showAndWait(), not .show(). Here's my rendition of a couple of the dialog types that are provided in Swing's OptionPane:
public class FXOptionPane {
public enum Response { NO, YES, CANCEL };
private static Response buttonSelected = Response.CANCEL;
private static ImageView icon = new ImageView();
static class Dialog extends Stage {
public Dialog( String title, Stage owner, Scene scene, String iconFile ) {
setTitle( title );
initStyle( StageStyle.UTILITY );
initModality( Modality.APPLICATION_MODAL );
initOwner( owner );
setResizable( false );
setScene( scene );
icon.setImage( new Image( getClass().getResourceAsStream( iconFile ) ) );
}
public void showDialog() {
sizeToScene();
centerOnScreen();
showAndWait();
}
}
static class Message extends Text {
public Message( String msg ) {
super( msg );
setWrappingWidth( 250 );
}
}
public static Response showConfirmDialog( Stage owner, String message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Confirm.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button yesButton = new Button( "Yes" );
yesButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.YES;
}
} );
Button noButton = new Button( "No" );
noButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
buttonSelected = Response.NO;
}
} );
BorderPane bp = new BorderPane();
HBox buttons = new HBox();
buttons.setAlignment( Pos.CENTER );
buttons.setSpacing( 10 );
buttons.getChildren().addAll( yesButton, noButton );
bp.setCenter( buttons );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, new Message( message ) );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
return buttonSelected;
}
public static void showMessageDialog( Stage owner, String message, String title ) {
showMessageDialog( owner, new Message( message ), title );
}
public static void showMessageDialog( Stage owner, Node message, String title ) {
VBox vb = new VBox();
Scene scene = new Scene( vb );
final Dialog dial = new Dialog( title, owner, scene, "res/Info.png" );
vb.setPadding( new Inset(10,10,10,10) );
vb.setSpacing( 10 );
Button okButton = new Button( "OK" );
okButton.setAlignment( Pos.CENTER );
okButton.setOnAction( new EventHandler<ActionEvent>() {
@Override public void handle( ActionEvent e ) {
dial.close();
}
} );
BorderPane bp = new BorderPane();
bp.setCenter( okButton );
HBox msg = new HBox();
msg.setSpacing( 5 );
msg.getChildren().addAll( icon, message );
vb.getChildren().addAll( msg, bp );
dial.showDialog();
}
}
edited Jul 29 '14 at 18:49
user3888927
32
32
answered Oct 3 '12 at 23:04
OtherBrotherDarrylOtherBrotherDarryl
140110
140110
1
Was trying to run your class but the compiler chokes on Layout - apparently the constants used. Which import did you use?
– likejudo
Jan 15 '13 at 4:40
How does one get the response i.e. which button was selected? the member variable buttonSelected is private.
– likejudo
Jan 15 '13 at 5:16
got it to compile and made buttonSelected public but calling it like this does not display anything. ` Stage stage = new Stage(StageStyle.TRANSPARENT); FXOptionPane.showConfirmDialog(stage, "Do you wish to disconnect?", "my title"); `
– likejudo
Jan 15 '13 at 5:28
add a comment |
1
Was trying to run your class but the compiler chokes on Layout - apparently the constants used. Which import did you use?
– likejudo
Jan 15 '13 at 4:40
How does one get the response i.e. which button was selected? the member variable buttonSelected is private.
– likejudo
Jan 15 '13 at 5:16
got it to compile and made buttonSelected public but calling it like this does not display anything. ` Stage stage = new Stage(StageStyle.TRANSPARENT); FXOptionPane.showConfirmDialog(stage, "Do you wish to disconnect?", "my title"); `
– likejudo
Jan 15 '13 at 5:28
1
1
Was trying to run your class but the compiler chokes on Layout - apparently the constants used. Which import did you use?
– likejudo
Jan 15 '13 at 4:40
Was trying to run your class but the compiler chokes on Layout - apparently the constants used. Which import did you use?
– likejudo
Jan 15 '13 at 4:40
How does one get the response i.e. which button was selected? the member variable buttonSelected is private.
– likejudo
Jan 15 '13 at 5:16
How does one get the response i.e. which button was selected? the member variable buttonSelected is private.
– likejudo
Jan 15 '13 at 5:16
got it to compile and made buttonSelected public but calling it like this does not display anything. ` Stage stage = new Stage(StageStyle.TRANSPARENT); FXOptionPane.showConfirmDialog(stage, "Do you wish to disconnect?", "my title"); `
– likejudo
Jan 15 '13 at 5:28
got it to compile and made buttonSelected public but calling it like this does not display anything. ` Stage stage = new Stage(StageStyle.TRANSPARENT); FXOptionPane.showConfirmDialog(stage, "Do you wish to disconnect?", "my title"); `
– likejudo
Jan 15 '13 at 5:28
add a comment |
Adapted from answer here: https://stackoverflow.com/a/7505528/921224
javafx.scene.control.Alert
For a an in depth description of how to use JavaFX dialogs see: JavaFX Dialogs (official) by code.makery. They are much more powerful and flexible than Swing dialogs and capable of far more than just popping up messages.
import javafx.scene.control.Alert
import javafx.scene.control.Alert.AlertType;
import javafx.application.Platform;
public class ClassNameHere
{
public static void infoBox(String infoMessage, String titleBar)
{
/* By specifying a null headerMessage String, we cause the dialog to
not have a header */
infoBox(infoMessage, titleBar, null);
}
public static void infoBox(String infoMessage, String titleBar, String headerMessage)
{
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(titleBar);
alert.setHeaderText(headerMessage);
alert.setContentText(infoMessage);
alert.showAndWait();
}
}
One thing to keep in mind is that JavaFX is a single threaded GUI toolkit, which means this method should be called directly from the JavaFX application thread. If you have another thread doing work, which needs a dialog then see these SO Q&As: JavaFX2: Can I pause a background Task / Service? and Platform.Runlater and Task Javafx.
To use this method call:
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE");
or
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE", "HEADER MESSAGE");
Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question.
– Martijn Pieters♦
Jun 10 '15 at 14:54
1
@MartijnPieters The original question specifies Swing as a tag but is open to general Java dialogs (it was asked before JavaFX was really a thing), if anything the JavaFX content I posted there is slightly off topic, yet useful to newbies who find that Q&A while looking for Java Dialogs and don't realise that Swing is going out of date.
– Troyseph
Jun 10 '15 at 15:26
All the more reason then to tailor your answer to the context then!
– Martijn Pieters♦
Jun 10 '15 at 15:51
I found this topic on google, so it's better to have information right here than to enter question topic to see the answer i need. This answer deserves more votes.
– Mateus Viccari
Sep 16 '15 at 13:32
add a comment |
Adapted from answer here: https://stackoverflow.com/a/7505528/921224
javafx.scene.control.Alert
For a an in depth description of how to use JavaFX dialogs see: JavaFX Dialogs (official) by code.makery. They are much more powerful and flexible than Swing dialogs and capable of far more than just popping up messages.
import javafx.scene.control.Alert
import javafx.scene.control.Alert.AlertType;
import javafx.application.Platform;
public class ClassNameHere
{
public static void infoBox(String infoMessage, String titleBar)
{
/* By specifying a null headerMessage String, we cause the dialog to
not have a header */
infoBox(infoMessage, titleBar, null);
}
public static void infoBox(String infoMessage, String titleBar, String headerMessage)
{
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(titleBar);
alert.setHeaderText(headerMessage);
alert.setContentText(infoMessage);
alert.showAndWait();
}
}
One thing to keep in mind is that JavaFX is a single threaded GUI toolkit, which means this method should be called directly from the JavaFX application thread. If you have another thread doing work, which needs a dialog then see these SO Q&As: JavaFX2: Can I pause a background Task / Service? and Platform.Runlater and Task Javafx.
To use this method call:
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE");
or
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE", "HEADER MESSAGE");
Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question.
– Martijn Pieters♦
Jun 10 '15 at 14:54
1
@MartijnPieters The original question specifies Swing as a tag but is open to general Java dialogs (it was asked before JavaFX was really a thing), if anything the JavaFX content I posted there is slightly off topic, yet useful to newbies who find that Q&A while looking for Java Dialogs and don't realise that Swing is going out of date.
– Troyseph
Jun 10 '15 at 15:26
All the more reason then to tailor your answer to the context then!
– Martijn Pieters♦
Jun 10 '15 at 15:51
I found this topic on google, so it's better to have information right here than to enter question topic to see the answer i need. This answer deserves more votes.
– Mateus Viccari
Sep 16 '15 at 13:32
add a comment |
Adapted from answer here: https://stackoverflow.com/a/7505528/921224
javafx.scene.control.Alert
For a an in depth description of how to use JavaFX dialogs see: JavaFX Dialogs (official) by code.makery. They are much more powerful and flexible than Swing dialogs and capable of far more than just popping up messages.
import javafx.scene.control.Alert
import javafx.scene.control.Alert.AlertType;
import javafx.application.Platform;
public class ClassNameHere
{
public static void infoBox(String infoMessage, String titleBar)
{
/* By specifying a null headerMessage String, we cause the dialog to
not have a header */
infoBox(infoMessage, titleBar, null);
}
public static void infoBox(String infoMessage, String titleBar, String headerMessage)
{
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(titleBar);
alert.setHeaderText(headerMessage);
alert.setContentText(infoMessage);
alert.showAndWait();
}
}
One thing to keep in mind is that JavaFX is a single threaded GUI toolkit, which means this method should be called directly from the JavaFX application thread. If you have another thread doing work, which needs a dialog then see these SO Q&As: JavaFX2: Can I pause a background Task / Service? and Platform.Runlater and Task Javafx.
To use this method call:
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE");
or
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE", "HEADER MESSAGE");
Adapted from answer here: https://stackoverflow.com/a/7505528/921224
javafx.scene.control.Alert
For a an in depth description of how to use JavaFX dialogs see: JavaFX Dialogs (official) by code.makery. They are much more powerful and flexible than Swing dialogs and capable of far more than just popping up messages.
import javafx.scene.control.Alert
import javafx.scene.control.Alert.AlertType;
import javafx.application.Platform;
public class ClassNameHere
{
public static void infoBox(String infoMessage, String titleBar)
{
/* By specifying a null headerMessage String, we cause the dialog to
not have a header */
infoBox(infoMessage, titleBar, null);
}
public static void infoBox(String infoMessage, String titleBar, String headerMessage)
{
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(titleBar);
alert.setHeaderText(headerMessage);
alert.setContentText(infoMessage);
alert.showAndWait();
}
}
One thing to keep in mind is that JavaFX is a single threaded GUI toolkit, which means this method should be called directly from the JavaFX application thread. If you have another thread doing work, which needs a dialog then see these SO Q&As: JavaFX2: Can I pause a background Task / Service? and Platform.Runlater and Task Javafx.
To use this method call:
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE");
or
ClassNameHere.infoBox("YOUR INFORMATION HERE", "TITLE BAR MESSAGE", "HEADER MESSAGE");
edited May 23 '17 at 12:03
Community♦
11
11
answered Jun 10 '15 at 14:07
TroysephTroyseph
3,08432948
3,08432948
Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question.
– Martijn Pieters♦
Jun 10 '15 at 14:54
1
@MartijnPieters The original question specifies Swing as a tag but is open to general Java dialogs (it was asked before JavaFX was really a thing), if anything the JavaFX content I posted there is slightly off topic, yet useful to newbies who find that Q&A while looking for Java Dialogs and don't realise that Swing is going out of date.
– Troyseph
Jun 10 '15 at 15:26
All the more reason then to tailor your answer to the context then!
– Martijn Pieters♦
Jun 10 '15 at 15:51
I found this topic on google, so it's better to have information right here than to enter question topic to see the answer i need. This answer deserves more votes.
– Mateus Viccari
Sep 16 '15 at 13:32
add a comment |
Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question.
– Martijn Pieters♦
Jun 10 '15 at 14:54
1
@MartijnPieters The original question specifies Swing as a tag but is open to general Java dialogs (it was asked before JavaFX was really a thing), if anything the JavaFX content I posted there is slightly off topic, yet useful to newbies who find that Q&A while looking for Java Dialogs and don't realise that Swing is going out of date.
– Troyseph
Jun 10 '15 at 15:26
All the more reason then to tailor your answer to the context then!
– Martijn Pieters♦
Jun 10 '15 at 15:51
I found this topic on google, so it's better to have information right here than to enter question topic to see the answer i need. This answer deserves more votes.
– Mateus Viccari
Sep 16 '15 at 13:32
Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question.
– Martijn Pieters♦
Jun 10 '15 at 14:54
Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question.
– Martijn Pieters♦
Jun 10 '15 at 14:54
1
1
@MartijnPieters The original question specifies Swing as a tag but is open to general Java dialogs (it was asked before JavaFX was really a thing), if anything the JavaFX content I posted there is slightly off topic, yet useful to newbies who find that Q&A while looking for Java Dialogs and don't realise that Swing is going out of date.
– Troyseph
Jun 10 '15 at 15:26
@MartijnPieters The original question specifies Swing as a tag but is open to general Java dialogs (it was asked before JavaFX was really a thing), if anything the JavaFX content I posted there is slightly off topic, yet useful to newbies who find that Q&A while looking for Java Dialogs and don't realise that Swing is going out of date.
– Troyseph
Jun 10 '15 at 15:26
All the more reason then to tailor your answer to the context then!
– Martijn Pieters♦
Jun 10 '15 at 15:51
All the more reason then to tailor your answer to the context then!
– Martijn Pieters♦
Jun 10 '15 at 15:51
I found this topic on google, so it's better to have information right here than to enter question topic to see the answer i need. This answer deserves more votes.
– Mateus Viccari
Sep 16 '15 at 13:32
I found this topic on google, so it's better to have information right here than to enter question topic to see the answer i need. This answer deserves more votes.
– Mateus Viccari
Sep 16 '15 at 13:32
add a comment |
- You can have a look to the great tool JavaFX Dialogs are simple dialogs in the style of JOptionPane from Swing
add a comment |
- You can have a look to the great tool JavaFX Dialogs are simple dialogs in the style of JOptionPane from Swing
add a comment |
- You can have a look to the great tool JavaFX Dialogs are simple dialogs in the style of JOptionPane from Swing
- You can have a look to the great tool JavaFX Dialogs are simple dialogs in the style of JOptionPane from Swing
answered May 16 '13 at 8:45
Khaled LelaKhaled Lela
2,84122250
2,84122250
add a comment |
add a comment |
You can give dialog box which given by the JavaFX UI Controls Project. I think it will help you
Dialogs.showErrorDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
Dialogs.showWarningDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
1
There are no such dialog classes in JavaFX 2.x
– jewelsea
Jul 17 '13 at 7:26
javafx-dialogs-0.0.3.jar You can download this jar and then you can work with the same dialog box.
– Rajeev Gupta
Jul 24 '13 at 7:10
I edited your post to link to the 3rd party JavaFX dialogs project Rajeev referenced. I think it is an older version of the dialogs from ControlsFX.
– jewelsea
Jul 24 '13 at 7:44
Yes , but its working fine.
– Rajeev Gupta
Jul 24 '13 at 9:42
add a comment |
You can give dialog box which given by the JavaFX UI Controls Project. I think it will help you
Dialogs.showErrorDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
Dialogs.showWarningDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
1
There are no such dialog classes in JavaFX 2.x
– jewelsea
Jul 17 '13 at 7:26
javafx-dialogs-0.0.3.jar You can download this jar and then you can work with the same dialog box.
– Rajeev Gupta
Jul 24 '13 at 7:10
I edited your post to link to the 3rd party JavaFX dialogs project Rajeev referenced. I think it is an older version of the dialogs from ControlsFX.
– jewelsea
Jul 24 '13 at 7:44
Yes , but its working fine.
– Rajeev Gupta
Jul 24 '13 at 9:42
add a comment |
You can give dialog box which given by the JavaFX UI Controls Project. I think it will help you
Dialogs.showErrorDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
Dialogs.showWarningDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
You can give dialog box which given by the JavaFX UI Controls Project. I think it will help you
Dialogs.showErrorDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
Dialogs.showWarningDialog(Stage object, errorMessage, "Main line", "Name of Dialog box");
edited Jul 24 '13 at 7:42
jewelsea
112k8265318
112k8265318
answered Jul 17 '13 at 6:53
Rajeev GuptaRajeev Gupta
916
916
1
There are no such dialog classes in JavaFX 2.x
– jewelsea
Jul 17 '13 at 7:26
javafx-dialogs-0.0.3.jar You can download this jar and then you can work with the same dialog box.
– Rajeev Gupta
Jul 24 '13 at 7:10
I edited your post to link to the 3rd party JavaFX dialogs project Rajeev referenced. I think it is an older version of the dialogs from ControlsFX.
– jewelsea
Jul 24 '13 at 7:44
Yes , but its working fine.
– Rajeev Gupta
Jul 24 '13 at 9:42
add a comment |
1
There are no such dialog classes in JavaFX 2.x
– jewelsea
Jul 17 '13 at 7:26
javafx-dialogs-0.0.3.jar You can download this jar and then you can work with the same dialog box.
– Rajeev Gupta
Jul 24 '13 at 7:10
I edited your post to link to the 3rd party JavaFX dialogs project Rajeev referenced. I think it is an older version of the dialogs from ControlsFX.
– jewelsea
Jul 24 '13 at 7:44
Yes , but its working fine.
– Rajeev Gupta
Jul 24 '13 at 9:42
1
1
There are no such dialog classes in JavaFX 2.x
– jewelsea
Jul 17 '13 at 7:26
There are no such dialog classes in JavaFX 2.x
– jewelsea
Jul 17 '13 at 7:26
javafx-dialogs-0.0.3.jar You can download this jar and then you can work with the same dialog box.
– Rajeev Gupta
Jul 24 '13 at 7:10
javafx-dialogs-0.0.3.jar You can download this jar and then you can work with the same dialog box.
– Rajeev Gupta
Jul 24 '13 at 7:10
I edited your post to link to the 3rd party JavaFX dialogs project Rajeev referenced. I think it is an older version of the dialogs from ControlsFX.
– jewelsea
Jul 24 '13 at 7:44
I edited your post to link to the 3rd party JavaFX dialogs project Rajeev referenced. I think it is an older version of the dialogs from ControlsFX.
– jewelsea
Jul 24 '13 at 7:44
Yes , but its working fine.
– Rajeev Gupta
Jul 24 '13 at 9:42
Yes , but its working fine.
– Rajeev Gupta
Jul 24 '13 at 9:42
add a comment |
public myClass{
private Stage dialogStage;
public void msgBox(String title){
dialogStage = new Stage();
GridPane grd_pan = new GridPane();
grd_pan.setAlignment(Pos.CENTER);
grd_pan.setHgap(10);
grd_pan.setVgap(10);//pading
Scene scene =new Scene(grd_pan,300,150);
dialogStage.setScene(scene);
dialogStage.setTitle("alert");
dialogStage.initModality(Modality.WINDOW_MODAL);
Label lab_alert= new Label(title);
grd_pan.add(lab_alert, 0, 1);
Button btn_ok = new Button("fermer");
btn_ok.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
// TODO Auto-generated method stub
dialogStage.hide();
}
});
grd_pan.add(btn_ok, 0, 2);
dialogStage.show();
}
}
2
It's probably a good idea to at least explain what your code is doing; there's fairly strong opinions on whether or not code-only answers are okay.
– Dennis Meng
May 30 '14 at 22:13
add a comment |
public myClass{
private Stage dialogStage;
public void msgBox(String title){
dialogStage = new Stage();
GridPane grd_pan = new GridPane();
grd_pan.setAlignment(Pos.CENTER);
grd_pan.setHgap(10);
grd_pan.setVgap(10);//pading
Scene scene =new Scene(grd_pan,300,150);
dialogStage.setScene(scene);
dialogStage.setTitle("alert");
dialogStage.initModality(Modality.WINDOW_MODAL);
Label lab_alert= new Label(title);
grd_pan.add(lab_alert, 0, 1);
Button btn_ok = new Button("fermer");
btn_ok.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
// TODO Auto-generated method stub
dialogStage.hide();
}
});
grd_pan.add(btn_ok, 0, 2);
dialogStage.show();
}
}
2
It's probably a good idea to at least explain what your code is doing; there's fairly strong opinions on whether or not code-only answers are okay.
– Dennis Meng
May 30 '14 at 22:13
add a comment |
public myClass{
private Stage dialogStage;
public void msgBox(String title){
dialogStage = new Stage();
GridPane grd_pan = new GridPane();
grd_pan.setAlignment(Pos.CENTER);
grd_pan.setHgap(10);
grd_pan.setVgap(10);//pading
Scene scene =new Scene(grd_pan,300,150);
dialogStage.setScene(scene);
dialogStage.setTitle("alert");
dialogStage.initModality(Modality.WINDOW_MODAL);
Label lab_alert= new Label(title);
grd_pan.add(lab_alert, 0, 1);
Button btn_ok = new Button("fermer");
btn_ok.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
// TODO Auto-generated method stub
dialogStage.hide();
}
});
grd_pan.add(btn_ok, 0, 2);
dialogStage.show();
}
}
public myClass{
private Stage dialogStage;
public void msgBox(String title){
dialogStage = new Stage();
GridPane grd_pan = new GridPane();
grd_pan.setAlignment(Pos.CENTER);
grd_pan.setHgap(10);
grd_pan.setVgap(10);//pading
Scene scene =new Scene(grd_pan,300,150);
dialogStage.setScene(scene);
dialogStage.setTitle("alert");
dialogStage.initModality(Modality.WINDOW_MODAL);
Label lab_alert= new Label(title);
grd_pan.add(lab_alert, 0, 1);
Button btn_ok = new Button("fermer");
btn_ok.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
// TODO Auto-generated method stub
dialogStage.hide();
}
});
grd_pan.add(btn_ok, 0, 2);
dialogStage.show();
}
}
answered May 30 '14 at 21:55
ayadiayadi
5816
5816
2
It's probably a good idea to at least explain what your code is doing; there's fairly strong opinions on whether or not code-only answers are okay.
– Dennis Meng
May 30 '14 at 22:13
add a comment |
2
It's probably a good idea to at least explain what your code is doing; there's fairly strong opinions on whether or not code-only answers are okay.
– Dennis Meng
May 30 '14 at 22:13
2
2
It's probably a good idea to at least explain what your code is doing; there's fairly strong opinions on whether or not code-only answers are okay.
– Dennis Meng
May 30 '14 at 22:13
It's probably a good idea to at least explain what your code is doing; there's fairly strong opinions on whether or not code-only answers are okay.
– Dennis Meng
May 30 '14 at 22:13
add a comment |
This working since java 8u40:
Alert alert = new Alert(AlertType.INFORMATION, "Content here", ButtonType.OK)
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE)
alert.show()
add a comment |
This working since java 8u40:
Alert alert = new Alert(AlertType.INFORMATION, "Content here", ButtonType.OK)
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE)
alert.show()
add a comment |
This working since java 8u40:
Alert alert = new Alert(AlertType.INFORMATION, "Content here", ButtonType.OK)
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE)
alert.show()
This working since java 8u40:
Alert alert = new Alert(AlertType.INFORMATION, "Content here", ButtonType.OK)
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE)
alert.show()
answered Apr 29 '16 at 12:34
Clairton LuzClairton Luz
72687
72687
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8309981%2fhow-to-create-and-show-common-dialog-error-warning-confirmation-in-javafx-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Perhaps you like to have a look on project for private use: github.com/4ntoine/JavaFxDialog/wiki
– BudMinton
Sep 5 '12 at 13:55
Backport of JavaFX 8 dialogs to JDK7: github.com/BertelSpA/openjfx-dialogs-jdk7
– Paolo Fulgoni
Jun 16 '15 at 9:00