org.jpedal.examples.viewer.gui.javafx.dialog.FXOptionDialog Maven / Gradle / Ivy
Show all versions of OpenViewerFX Show documentation
/*
* ===========================================
* Java Pdf Extraction Decoding Access Library
* ===========================================
*
* Project Info: http://www.idrsolutions.com
* Help section for developers at http://www.idrsolutions.com/support/
*
* (C) Copyright 1997-2017 IDRsolutions and Contributors.
*
* This file is part of JPedal/JPDF2HTML5
*
@LICENSE@
*
* ---------------
* FXOptionDialog.java
* ---------------
*/
package org.jpedal.examples.viewer.gui.javafx.dialog;
import java.util.ArrayList;
import java.util.List;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.stage.Stage;
/**
* Option dialog allows for a user to specify a choice.
*
* *_OPTION allows for a predefined option set to be used.
* This will be overriden by passing the options array in.
* The options array allows you to define your own input options.
*
* The return value from showOptionsDialog() will go from 0 at the left to the maximum button count -1
*
* @author Simon
*/
public class FXOptionDialog extends FXMessageDialog {
public static final int DEFAULT_OPTION = -1;
public static final int YES_NO_OPTION = 0;
public static final int YES_NO_CANCEL_OPTION = 1;
public static final int OK_CANCEL_OPTION = 2;
public static final int CLOSED_OPTION = -1;
public static final int YES_OPTION = 0;
public static final int OK_OPTION = 0;
public static final int NO_OPTION = 1;
public static final int CANCEL_OPTION = 2;
private int choice = -1;
public FXOptionDialog(final Stage parent, final String message, final String title, final int optionType, final Object[] options, final Object initialValue) {
super(parent, message);
setTitle(title);
setupButtons(optionType, options, initialValue);
}
public FXOptionDialog(final Stage parent, final Object message, final String title, final int optionType, final Object[] options, final Object initialValue) {
super(parent, message.toString());
setTitle(title);
setupButtons(optionType, options, initialValue);
}
private void setupButtons(final int optionType, final Object[] options, final Object initialValue) {
final List