Dialogs

Paweł Pastuszak edited this page Jun 26, 2016 · 3 revisions

Dialogs (source) is a utility class for displaying well... dialogs. It can display these types of dialog:

  • Standard confirmation dialog with OK button.
  • Option dialog with buttons like Yes, No, Cancel
  • Error dialog with OK button
  • Error dialog with OK button, and Details button Showcase
  • Input dialog Screenshot
  • Input dialog with validator (see VisValidableTextField)

Dialogs has only static methods.

showOKDialog (Stage stage, String title, String text)

//without details
showErrorDialog (Stage stage, String text)

//with stacktrace as details
showErrorDialog (Stage stage, String text, Exception exception)

//with custom details
showErrorDialog (Stage stage, String text, String details)

//option dialog (return OptionDialog because you may want to change buttons text)
OptionDialog showOptionDialog (Stage stage, String title, String text, OptionDialogType type, final OptionDialogListener listener)

Input dialog examples:

//input dialog
Dialogs.showInputDialog(getStage(), "enter your name", "name: ", new InputDialogAdapter() {
	@Override
	public void finished (String input) {
		Dialogs.showOKDialog(getStage(), "result", "your name is: " + input);
	}
});

//input dialog that only allows to enter integer
//see IntegerValidator: https://github.com/kotcrab/vis-editor/blob/master/ui/src/test/java/com/kotcrab/vis/ui/test/IntegerValidator.java
Dialogs.showInputDialog(getStage(), "enter int number", null, new IntegerValidator(), new InputDialogAdapter() {
	@Override
	public void finished (String input) {
		Dialogs.showOKDialog(getStage(), "result", "you entered: " + input);
	}
});
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.