All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.invation.code.toval.graphic.dialog.ConditionalInputDialog Maven / Gradle / Ivy

Go to download

TOVAL comprises a set of java classes for common programming issues. It includes utils for arrays, lists, sets and collections for convenient handling and modification, but also support for mathematic definitions concerning logic (clauses + resolution) together with some algorithms for permutations, powersets and resolution. Additionally it contains a number of types for multisets, matrices with object keys and much more.

The newest version!
package de.invation.code.toval.graphic.dialog;

import java.awt.Window;

import javax.swing.JOptionPane;

/**
 * 
 * @author Thomas Stocker
 */
public abstract class ConditionalInputDialog {
	
	protected Window parent = null;
	private String title = null;
	private String message = null;

	public ConditionalInputDialog(Window parent, String message,  String title) {
		this.parent = parent;
		this.title = title;
		this.message = message;
	}
	
	public String requestInput(){
		String input = null;
		while(((input = JOptionPane.showInputDialog(parent, message, title, JOptionPane.QUESTION_MESSAGE)) != null) && !isValid(input)){
			JOptionPane.showMessageDialog(parent, getErrorMessage(), "Invalid input", JOptionPane.ERROR_MESSAGE);
			input = null;
		}
		return input;
	}
	
	protected abstract String getErrorMessage();

	protected abstract boolean isValid(String input);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy