Java Code Examples for javax.swing.JOptionPane.UNINITIALIZED_VALUE

The following are Jave code examples for showing how to use UNINITIALIZED_VALUE of the javax.swing.JOptionPane class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DeutschSim   File: CustomGatePrompt.java   View Source Code Vote up 6 votes
@Override
public void propertyChange(PropertyChangeEvent ev) {
	final String prop = ev.getPropertyName();
	if (isVisible()
			&& ev.getSource() == option_pane
			&& (JOptionPane.VALUE_PROPERTY.equals(prop)
			|| JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
		if (option_pane.getValue() == JOptionPane.UNINITIALIZED_VALUE)
			return;
		option_pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
		
		final Component selected_panel = tabbed_pane.getSelectedComponent();
		if (selected_panel == rotation_panel)
			create_rotation_gate();
		else if (selected_panel == phase_shift_panel) {
			create_phase_shift_gate();
		} else if (selected_panel == matrix_panel) {
			create_matrix_gate();
		} else
			throw new RuntimeException("Selected tab is not listed in the tabbed panel");
	}
}
 
Example 2
Project: freecol   File: FreeColDialog.java   View Source Code Vote up 5 votes
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    // Let the defaultCloseOperation handle the closing if the
    // user closed the window without selecting a button (in which
    // case the new value will be null).  Otherwise, close the dialog.
    if (this.isVisible()
        && e.getSource() == pane
        && (JOptionPane.VALUE_PROPERTY.equals(e.getPropertyName())
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(e.getPropertyName()))
        && e.getNewValue() != null
        && e.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
        this.setVisible(false);
    }
}
 
Example 3
Project: FreeCol   File: FreeColDialog.java   View Source Code Vote up 5 votes
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    // Let the defaultCloseOperation handle the closing if the
    // user closed the window without selecting a button (in which
    // case the new value will be null).  Otherwise, close the dialog.
    if (this.isVisible()
        && e.getSource() == pane
        && (JOptionPane.VALUE_PROPERTY.equals(e.getPropertyName())
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(e.getPropertyName()))
        && e.getNewValue() != null
        && e.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
        this.setVisible(false);
    }
}
 
Example 4
Project: jmt   File: CustomDialog.java   View Source Code Vote up 4 votes
/** This method reacts to state changes in the option pane. */
public void propertyChange(PropertyChangeEvent e) {
	String prop = e.getPropertyName();

	if (isVisible() && (e.getSource() == optionPane)
			&& (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
		Object value = optionPane.getValue();

		if (value == JOptionPane.UNINITIALIZED_VALUE) {
			//ignore reset
			return;
		}

		//Reset the JOptionPane's value.
		//If you do not do this, then if the user
		//presses the same button next time, no
		//property change event will be fired.
		optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

		if (btnString1.equals(value)) {
			if (nolimitRB.isSelected()) {
				typedText = "unlimited";
				typedValue = 0;
				clearAndHide();
			} else {
				typedText = textField.getText();
				try {
					typedValue = Integer.parseInt(typedText);
				} catch (NumberFormatException nfe) {
					typedValue = 0;
				}
				if ((typedValue > 100000) || (typedValue < 1)) {
					//text was invalid
					textField.selectAll();
					JOptionPane.showMessageDialog(CustomDialog.this, "Sorry, '" + typedValue + "' " + "is not a valid response.\n"
							+ "Please enter a number between 1 and 100'000.", "Please try again", JOptionPane.ERROR_MESSAGE);
					typedText = null;
					typedValue = 0;
					textField.requestFocusInWindow();
				} else {
					clearAndHide();
				}
			}
		} else { //user closed dialog or clicked cancel
			typedValue = 0;
			typedText = null;
			clearAndHide();
		}
	}
}
 
Example 5
Project: jmt   File: CustomDialogMethod.java   View Source Code Vote up 4 votes
/** This method reacts to state changes in the option pane. */
public void propertyChange(PropertyChangeEvent e) {
	String prop = e.getPropertyName();

	if (isVisible() && (e.getSource() == optionPane)
			&& (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
		Object value = optionPane.getValue();

		if (value == JOptionPane.UNINITIALIZED_VALUE) {
			//ignore reset
			return;
		}

		//Reset the JOptionPane's value.
		//If you do not do this, then if the user
		//presses the same button next time, no
		//property change event will be fired.
		optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

		if (btnString1.equals(value)) {
			if (mm1RB.isSelected()) {
				selectedMethod = "mm1";
				typedValue = 0;
				clearAndHide();
			} else if (mm1kRB.isSelected()) {
				selectedMethod = "mm1k";
				typedValue = 0;
				clearAndHide();
			}

			else {

				if (mmnRB.isSelected()) {
					selectedMethod = "mmn";
				} else if (mmnkRB.isSelected()) {
					selectedMethod = "mmnk";
				}

				try {
					typedValue = Integer.parseInt(textField.getText());
				} catch (NumberFormatException nfe) {
					typedValue = 0;
				}
				if ((typedValue > maximumServer) || (typedValue < 1)) {
					//text was invalid
					textField.selectAll();
					JOptionPane.showMessageDialog(CustomDialogMethod.this, "Sorry, '" + typedValue + "' " + "is not a valid response.\n"
							+ "Please enter a number between 2 and " + maximumServer + ".", "Please try again", JOptionPane.ERROR_MESSAGE);
					selectedMethod = null;
					typedValue = 0;
					textField.requestFocusInWindow();
				} else {
					clearAndHide();
				}
			}
		} else { //user closed dialog or clicked cancel
			typedValue = 0;
			selectedMethod = null;
			clearAndHide();
		}
	}
}
 
Example 6
Project: marathonv5   File: CustomDialog.java   View Source Code Vote up 4 votes
/** This method reacts to state changes in the option pane. */
public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible() && (e.getSource() == optionPane)
            && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
        Object value = optionPane.getValue();

        if (value == JOptionPane.UNINITIALIZED_VALUE) {
            // ignore reset
            return;
        }

        // Reset the JOptionPane's value.
        // If you don't do this, then if the user
        // presses the same button next time, no
        // property change event will be fired.
        optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

        if (btnString1.equals(value)) {
            typedText = textField.getText();
            String ucText = typedText.toUpperCase();
            if (magicWord.equals(ucText)) {
                // we're done; clear and dismiss the dialog
                clearAndHide();
            } else {
                // text was invalid
                textField.selectAll();
                JOptionPane.showMessageDialog(CustomDialog.this,
                        "Sorry, \"" + typedText + "\" " + "isn't a valid response.\n" + "Please enter " + magicWord + ".",
                        "Try again", JOptionPane.ERROR_MESSAGE);
                typedText = null;
                textField.requestFocusInWindow();
            }
        } else { // user closed dialog or clicked cancel
            dd.setLabel("It's OK.  " + "We won't force you to type " + magicWord + ".");
            typedText = null;
            clearAndHide();
        }
    }
}
 
Example 7
Project: QN-ACTR-Release   File: CustomDialog.java   View Source Code Vote up 4 votes
/** This method reacts to state changes in the option pane. */
public void propertyChange(PropertyChangeEvent e) {
	String prop = e.getPropertyName();

	if (isVisible() && (e.getSource() == optionPane)
			&& (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
		Object value = optionPane.getValue();

		if (value == JOptionPane.UNINITIALIZED_VALUE) {
			//ignore reset
			return;
		}

		//Reset the JOptionPane's value.
		//If you don't do this, then if the user
		//presses the same button next time, no
		//property change event will be fired.
		optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

		if (btnString1.equals(value)) {
			if (nolimitRB.isSelected()) {
				typedText = "unlimited";
				typedValue = 0;
				clearAndHide();
			} else {
				typedText = textField.getText();
				try {
					typedValue = Integer.parseInt(typedText);
				} catch (NumberFormatException nfe) {
					typedValue = 0;
				}
				if ((typedValue > 100000) || (typedValue < 1)) {
					//text was invalid
					textField.selectAll();
					JOptionPane.showMessageDialog(CustomDialog.this, "Sorry, '" + typedValue + "' " + "isn't a valid response.\n"
							+ "Please enter a number between 1 and 100'000.", "Please try again", JOptionPane.ERROR_MESSAGE);
					typedText = null;
					typedValue = 0;
					textField.requestFocusInWindow();
				} else {
					clearAndHide();
				}
			}
		} else { //user closed dialog or clicked cancel
			typedValue = 0;
			typedText = null;
			clearAndHide();
		}
	}
}
 
Example 8
Project: QN-ACTR-Release   File: CustomDialogMethod.java   View Source Code Vote up 4 votes
/** This method reacts to state changes in the option pane. */
public void propertyChange(PropertyChangeEvent e) {
	String prop = e.getPropertyName();

	if (isVisible() && (e.getSource() == optionPane)
			&& (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
		Object value = optionPane.getValue();

		if (value == JOptionPane.UNINITIALIZED_VALUE) {
			//ignore reset
			return;
		}

		//Reset the JOptionPane's value.
		//If you don't do this, then if the user
		//presses the same button next time, no
		//property change event will be fired.
		optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

		if (btnString1.equals(value)) {
			if (mm1RB.isSelected()) {
				selectedMethod = "mm1";
				typedValue = 0;
				clearAndHide();
			} else if (mm1kRB.isSelected()) {
				selectedMethod = "mm1k";
				typedValue = 0;
				clearAndHide();
			}

			else {

				if (mmnRB.isSelected()) {
					selectedMethod = "mmn";
				} else if (mmnkRB.isSelected()) {
					selectedMethod = "mmnk";
				}

				try {
					typedValue = Integer.parseInt(textField.getText());
				} catch (NumberFormatException nfe) {
					typedValue = 0;
				}
				if ((typedValue > maximumServer) || (typedValue < 1)) {
					//text was invalid
					textField.selectAll();
					JOptionPane.showMessageDialog(CustomDialogMethod.this, "Sorry, '" + typedValue + "' " + "isn't a valid response.\n"
							+ "Please enter a number between 2 and " + maximumServer + ".", "Please try again", JOptionPane.ERROR_MESSAGE);
					selectedMethod = null;
					typedValue = 0;
					textField.requestFocusInWindow();
				} else {
					clearAndHide();
				}
			}
		} else { //user closed dialog or clicked cancel
			typedValue = 0;
			selectedMethod = null;
			clearAndHide();
		}
	}
}
 
Example 9
Project: freecol   File: FreeColDialog.java   View Source Code Vote up 2 votes
/**
 * Has this dialog been given a response.
 *
 * @return True if the dialog has a response.
 */
public synchronized boolean responded() {
    return this.pane != null
        && this.pane.getValue() != JOptionPane.UNINITIALIZED_VALUE;
}
 
Example 10
Project: FreeCol   File: FreeColDialog.java   View Source Code Vote up 2 votes
/**
 * Has this dialog been given a response.
 *
 * @return True if the dialog has a response.
 */
public synchronized boolean responded() {
    return this.pane != null
        && this.pane.getValue() != JOptionPane.UNINITIALIZED_VALUE;
}