本文整理匯總了Java中javax.swing.JOptionPane.addPropertyChangeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JOptionPane.addPropertyChangeListener方法的具體用法?Java JOptionPane.addPropertyChangeListener怎麽用?Java JOptionPane.addPropertyChangeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JOptionPane
的用法示例。
在下文中一共展示了JOptionPane.addPropertyChangeListener方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: CustomGatePrompt
import javax.swing.JOptionPane; //導入方法依賴的package包/類
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());
}
示例2: CustomDialog
import javax.swing.JOptionPane; //導入方法依賴的package包/類
/** 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);
}