433 /**
434 * Returns the message to display from the JOptionPane the receiver is
435 * providing the look and feel for.
436 */
437 protected Object getMessage() {
438 inputComponent = null;
439 if (optionPane != null) {
440 if (optionPane.getWantsInput()) {
441 /* Create a user component to capture the input. If the
442 selectionValues are non null the component and there
443 are < 20 values it'll be a combobox, if non null and
444 >= 20, it'll be a list, otherwise it'll be a textfield. */
445 Object message = optionPane.getMessage();
446 Object[] sValues = optionPane.getSelectionValues();
447 Object inputValue = optionPane
448 .getInitialSelectionValue();
449 JComponent toAdd;
450
451 if (sValues != null) {
452 if (sValues.length < 20) {
453 JComboBox cBox = new JComboBox();
454
455 cBox.setName("OptionPane.comboBox");
456 for(int counter = 0, maxCounter = sValues.length;
457 counter < maxCounter; counter++) {
458 cBox.addItem(sValues[counter]);
459 }
460 if (inputValue != null) {
461 cBox.setSelectedItem(inputValue);
462 }
463 inputComponent = cBox;
464 toAdd = cBox;
465
466 } else {
467 JList list = new JList(sValues);
468 JScrollPane sp = new JScrollPane(list);
469
470 sp.setName("OptionPane.scrollPane");
471 list.setName("OptionPane.list");
472 list.setVisibleRowCount(10);
473 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
474 if(inputValue != null)
475 list.setSelectedValue(inputValue, true);
476 list.addMouseListener(getHandler());
477 toAdd = sp;
478 inputComponent = list;
479 }
480
481 } else {
482 MultiplexingTextField tf = new MultiplexingTextField(20);
483
484 tf.setName("OptionPane.textField");
485 tf.setKeyStrokes(new KeyStroke[] {
486 KeyStroke.getKeyStroke("ENTER") } );
487 if (inputValue != null) {
1215 }
1216
1217
1218 //
1219 // MouseListener
1220 //
1221 public void mouseClicked(MouseEvent e) {
1222 }
1223
1224 public void mouseReleased(MouseEvent e) {
1225 }
1226
1227 public void mouseEntered(MouseEvent e) {
1228 }
1229
1230 public void mouseExited(MouseEvent e) {
1231 }
1232
1233 public void mousePressed(MouseEvent e) {
1234 if (e.getClickCount() == 2) {
1235 JList list = (JList)e.getSource();
1236 int index = list.locationToIndex(e.getPoint());
1237
1238 optionPane.setInputValue(list.getModel().getElementAt(index));
1239 optionPane.setValue(JOptionPane.OK_OPTION);
1240 }
1241 }
1242
1243 //
1244 // PropertyChangeListener
1245 //
1246 public void propertyChange(PropertyChangeEvent e) {
1247 if(e.getSource() == optionPane) {
1248 // Option Pane Auditory Cue Activation
1249 // only respond to "ancestor" changes
1250 // the idea being that a JOptionPane gets a JDialog when it is
1251 // set to appear and loses it's JDialog when it is dismissed.
1252 if ("ancestor" == e.getPropertyName()) {
1253 JOptionPane op = (JOptionPane)e.getSource();
1254 boolean isComingUp;
1255
|
433 /**
434 * Returns the message to display from the JOptionPane the receiver is
435 * providing the look and feel for.
436 */
437 protected Object getMessage() {
438 inputComponent = null;
439 if (optionPane != null) {
440 if (optionPane.getWantsInput()) {
441 /* Create a user component to capture the input. If the
442 selectionValues are non null the component and there
443 are < 20 values it'll be a combobox, if non null and
444 >= 20, it'll be a list, otherwise it'll be a textfield. */
445 Object message = optionPane.getMessage();
446 Object[] sValues = optionPane.getSelectionValues();
447 Object inputValue = optionPane
448 .getInitialSelectionValue();
449 JComponent toAdd;
450
451 if (sValues != null) {
452 if (sValues.length < 20) {
453 JComboBox<Object> cBox = new JComboBox<>();
454
455 cBox.setName("OptionPane.comboBox");
456 for(int counter = 0, maxCounter = sValues.length;
457 counter < maxCounter; counter++) {
458 cBox.addItem(sValues[counter]);
459 }
460 if (inputValue != null) {
461 cBox.setSelectedItem(inputValue);
462 }
463 inputComponent = cBox;
464 toAdd = cBox;
465
466 } else {
467 JList<Object> list = new JList<>(sValues);
468 JScrollPane sp = new JScrollPane(list);
469
470 sp.setName("OptionPane.scrollPane");
471 list.setName("OptionPane.list");
472 list.setVisibleRowCount(10);
473 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
474 if(inputValue != null)
475 list.setSelectedValue(inputValue, true);
476 list.addMouseListener(getHandler());
477 toAdd = sp;
478 inputComponent = list;
479 }
480
481 } else {
482 MultiplexingTextField tf = new MultiplexingTextField(20);
483
484 tf.setName("OptionPane.textField");
485 tf.setKeyStrokes(new KeyStroke[] {
486 KeyStroke.getKeyStroke("ENTER") } );
487 if (inputValue != null) {
1215 }
1216
1217
1218 //
1219 // MouseListener
1220 //
1221 public void mouseClicked(MouseEvent e) {
1222 }
1223
1224 public void mouseReleased(MouseEvent e) {
1225 }
1226
1227 public void mouseEntered(MouseEvent e) {
1228 }
1229
1230 public void mouseExited(MouseEvent e) {
1231 }
1232
1233 public void mousePressed(MouseEvent e) {
1234 if (e.getClickCount() == 2) {
1235 JList<?> list = (JList)e.getSource();
1236 int index = list.locationToIndex(e.getPoint());
1237
1238 optionPane.setInputValue(list.getModel().getElementAt(index));
1239 optionPane.setValue(JOptionPane.OK_OPTION);
1240 }
1241 }
1242
1243 //
1244 // PropertyChangeListener
1245 //
1246 public void propertyChange(PropertyChangeEvent e) {
1247 if(e.getSource() == optionPane) {
1248 // Option Pane Auditory Cue Activation
1249 // only respond to "ancestor" changes
1250 // the idea being that a JOptionPane gets a JDialog when it is
1251 // set to appear and loses it's JDialog when it is dismissed.
1252 if ("ancestor" == e.getPropertyName()) {
1253 JOptionPane op = (JOptionPane)e.getSource();
1254 boolean isComingUp;
1255
|