Java Code Examples for javax.swing.JOptionPane.addPropertyChangeListener()

The following are Jave code examples for showing how to use addPropertyChangeListener() 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 5 votes
public CustomGatePrompt(final JFrame frame) {
	super(frame, true);
	
	this.frame = frame;
	
	JPanel panel = new JPanel();
	panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
	
	gate_name = new TextEditor("Gate name", TextEditor.Type.SINGLE_LINE);
	panel.add(gate_name);
	
	tabbed_pane = new JTabbedPane();
	
	create_rotation_panel();
	tabbed_pane.add("Rotation", rotation_panel);
	
	create_phase_shift_panel();
	tabbed_pane.add("Phase Shift", phase_shift_panel);
	
	create_matrix_panel();
	tabbed_pane.add("Matrix", matrix_panel);
	
	tabbed_pane.addChangeListener(new TabbedPaneListener(tabbed_pane));
	panel.add(tabbed_pane);
	
	trig_selection = new AngleTypeSelection("What to represent arguments of " + 
			"trigonometric functions in?");
	panel.add(trig_selection);
	
	option_pane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_OPTION,
			null, new Object[] {"Create Gate"});
	
	setTitle("Create Custom Gate");
	setResizable(false);
	setContentPane(option_pane);
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	pack();
	
	option_pane.addPropertyChangeListener(new OKButtonListener());
}
 
Example 2
Project: marathonv5   File: CustomDialog.java   View Source Code Vote up 4 votes
/** Creates the reusable dialog. */
public CustomDialog(Frame aFrame, String aWord, DialogDemo parent) {
    super(aFrame, true);
    dd = parent;

    magicWord = aWord.toUpperCase();
    setTitle("Quiz");

    textField = new JTextField(10);

    // Create an array of the text and components to be displayed.
    String msgString1 = "What was Dr. SEUSS's real last name?";
    String msgString2 = "(The answer is \"" + magicWord + "\".)";
    Object[] array = { msgString1, msgString2, textField };

    // Create an array specifying the number of dialog buttons
    // and their text.
    Object[] options = { btnString1, btnString2 };

    // Create the JOptionPane.
    optionPane = new JOptionPane(array, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]);

    // Make this dialog display it.
    setContentPane(optionPane);

    // Handle window closing correctly.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            /*
             * Instead of directly closing the window, we're going to change
             * the JOptionPane's value property.
             */
            optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
        }
    });

    // Ensure the text field always gets the first focus.
    addComponentListener(new ComponentAdapter() {
        public void componentShown(ComponentEvent ce) {
            textField.requestFocusInWindow();
        }
    });

    // Register an event handler that puts the text into the option pane.
    textField.addActionListener(this);

    // Register an event handler that reacts to option pane state changes.
    optionPane.addPropertyChangeListener(this);
}