Java 类javax.swing.InputVerifier 实例源码

项目:incubator-netbeans    文件:RevertModifications.java   
private void initInputVerifiers () {
    InputVerifier iv = new InputVerifier() {
        @Override
        public boolean verify (JComponent input) {
            if (input == panel.startRevisionTextField || input == panel.endRevisionTextField || input == panel.oneRevisionTextField) {
                JTextComponent comp = (JTextComponent) input;
                if (comp.getText().trim().isEmpty()) {
                    comp.setText(SVNRevision.HEAD.toString());
                }
            }
            return true;
        }
    };
    panel.startRevisionTextField.setInputVerifier(iv);
    panel.endRevisionTextField.setInputVerifier(iv);
    panel.oneRevisionTextField.setInputVerifier(iv);
}
项目:KonnektingSuite    文件:CommObjectTable.java   
/**
 * Creates new form CommObjectTable
 */
public CommObjectTable() {
    RootEventBus.getDefault().registerSticky(this);
    InputVerifier gaVerifier = getGaInputVerifier();
    gaEditor = getGaTableCellEditor(gaVerifier);

    initComponents();
    table.setRowHeight(27); // enough space for textfields
    table.getColumnModel().getColumn(0).setPreferredWidth(30);
    table.getColumnModel().getColumn(1).setPreferredWidth(150);
    table.getColumnModel().getColumn(2).setPreferredWidth(120);
    table.getColumnModel().getColumn(3).setPreferredWidth(60);
    table.getColumnModel().getColumn(4).setPreferredWidth(150);
    table.getColumnModel().getColumn(5).setPreferredWidth(150);

    table.putClientProperty("terminateEditOnFocusLost", true);


}
项目:KonnektingSuite    文件:CommObjectTable.java   
private DefaultCellEditor getGaTableCellEditor(final InputVerifier verifier) {
    DefaultCellEditor editor = new DefaultCellEditor(new GroupAddressTextField()) {
        {
            getComponent().setInputVerifier(verifier);
        }

        @Override
        public boolean stopCellEditing() {
            if (!verifier.shouldYieldFocus(getComponent())) {
                return false;
            }
            System.out.println("Stopped editing: "+getComponent().getText());
            return super.stopCellEditing();
        }

        @Override
        public JTextField getComponent() {
            return (JTextField) super.getComponent();
        }

    };
    return editor;
}
项目:EP_Utilities    文件:TextChangeListener.java   
public void callUpdateIfReady()
{
    if (field==null)
    {
        // we can't do anything if field is null, just trigger update
        parent.update();
    }
    else
    {
        // we see if this class has a InputVerifier, if it does, we only call update
        // if it would return true
        InputVerifier validator = field.getInputVerifier();

        if (validator==null || validator.verify(field))
        {
            parent.update();
        }                       
    }
}
项目:panstamp-tools    文件:PanStampParamDialog.java   
private Component makeTextField(final Parameter par) throws NetworkException {
    final JTextField field = new JTextField();
    if (par.getRegister().hasValue()) {
        field.setText(par.getValue().toString());
    } else {
        field.setText(par.getDefault().toString());
    }
    field.setInputVerifier(new InputVerifier() {

        private final Pattern pattern = Pattern.compile(par.getPattern());

        @Override
        public boolean verify(JComponent input) {
            return (pattern.matcher(field.getText()).matches());
        }
    });
    return field;
}
项目:incubator-netbeans    文件:CheckoutStep.java   
public void setup(RepositoryFile repositoryFile) {
    if(repositoryPaths == null) {                    
        repositoryPaths = 
            new RepositoryPaths(
                    repositoryFile, 
                    workdirPanel.repositoryPathTextField, 
                    workdirPanel.browseRepositoryButton, 
                    workdirPanel.revisionTextField, 
                    workdirPanel.searchRevisionButton,
                    workdirPanel.browseRevisionButton
            );        
        String browserPurposeMessage = org.openide.util.NbBundle.getMessage(CheckoutStep.class, "LBL_BrowserMessage");
        int browserMode = Browser.BROWSER_SHOW_FILES | Browser.BROWSER_FOLDERS_SELECTION_ONLY;
        repositoryPaths.setupBehavior(browserPurposeMessage, browserMode, Browser.BROWSER_HELP_ID_CHECKOUT, SvnSearch.SEACRH_HELP_ID_CHECKOUT);
    } else {
        repositoryPaths.setRepositoryFile(repositoryFile);
    }                
    workdirPanel.repositoryPathTextField.setText(repositoryFile.getPath());
    refreshWorkingCopy(new RepositoryFile[] {repositoryFile});
    if(!repositoryFile.getRevision().equals(SVNRevision.HEAD)) {
        workdirPanel.revisionTextField.setText(repositoryFile.getRevision().toString());
    } else {
        workdirPanel.revisionTextField.setText(SVNRevision.HEAD.toString());
    }
    workdirPanel.revisionTextField.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify (JComponent input) {
            if (workdirPanel.revisionTextField.getText().trim().isEmpty()) {
                workdirPanel.revisionTextField.setText(SVNRevision.HEAD.toString());
            }
            return true;
        }
    });
    workdirPanel.scanForProjectsCheckBox.setSelected(SvnModuleConfig.getDefault().getShowCheckoutCompleted());
}
项目:swingx    文件:NumberEditorExtTest.java   
public void interactiveNumberInputVerifier() {
    final JFormattedTextField field = new JFormattedTextField(NumberFormat.getIntegerInstance()) {

        @Override
        protected void invalidEdit() {
            LOG.info("got invalid edit");
            super.invalidEdit();
        }

    };
    field.setText("20");
    try {
        field.commitEdit();
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    InputVerifier verifier = new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            boolean result = ((Number) field.getValue()).intValue() < 200;
            if (!result) LOG.info("in verifier");
            return result;
        }
    };
    field.setInputVerifier(verifier);
    final JFormattedTextField other = new JFormattedTextField(NumberFormat.getIntegerInstance());
    JComponent content = Box.createVerticalBox();
    content.add(field);
    content.add(other);
    showInFrame(content, "");
}
项目:OpenID-Attacker    文件:AttackOverviewGui.java   
/**
 * Creates new form AttackOverviewGui
 * @param idpType
 */
public AttackOverviewGui(final IdpType idpType) {
    initComponents();

    controller.setIdp(idpType);

    if (idpType.equals(IdpType.ANALYZER)) {
        performAttack.setEnabled(false);
        sendTokenToAttackerUrl.setEnabled(false);
    }

    // set speed for scrolling
    parameterScrollPane.getVerticalScrollBar().setUnitIncrement(16);

    AttackParameterKeeper keeper = controller.getServer().getParameterConfiguration();
    ObservableList<AttackParameter> list = (ObservableList<AttackParameter>) keeper.getParameterList();
    list.addObservableListListener(this);
    newParameterName.setInputVerifier(new InputVerifier() {
        final private AttackParameterKeeper parameters = controller.getServer().getParameterConfiguration();

        @Override
        public boolean verify(JComponent jc) {
            String newName = newParameterName.getText();
            boolean contained = parameters.hasParameter(newName);
            if (contained) {
                errorLabel.setText(String.format("Parameter '%s' already exist", newName));
            } else {
                errorLabel.setText("");
            }
            return !contained;
        }
    });
}
项目:swing    文件:RangeBoundedDecimalTextField.java   
private InputVerifier buildInputVerifier() {
    return new InputVerifier() {
        @Override
        public boolean verify(JComponent component) {
            return isValid(parseDecimalText());
        }
    };
}
项目:masters-of-java-software    文件:TeamProfileListManager.java   
public boolean shouldYieldFocus(JComponent input) {
    msg = null;
    boolean result = super.shouldYieldFocus(input);
    if ((!result) && (msg != null)) {
        InputVerifier old = input.getInputVerifier();
        // Neccecary to prevent endless popups.
        input.setInputVerifier(null);
        try {
            JOptionPane.showMessageDialog(input, msg);
        } finally {
            input.setInputVerifier(old);
        }
    }
    return result;
}
项目:wandora    文件:PingerPanel.java   
/**
 * Creates new form PingerPanel
 * @param tm
 */
public PingerPanel(TopicMap tm) {
    this.tm = tm;
    isRunning = false;

    try {
        maybeTargetButton = new GetTopicButton();
        maybeSourceButton = new GetTopicButton();
    } 
    catch (Exception e) {
        return;
    }

    initComponents();

    InputVerifier verifier = new InputVerifier(){
        @Override
        public boolean verify(JComponent input) {
            JFormattedTextField tf = (JFormattedTextField)input;
            int v = Integer.parseInt(tf.getText());
            return v >= 0;
        }
    };

    yearField.setInputVerifier(verifier);
    monthField.setInputVerifier(verifier);
    dayField.setInputVerifier(verifier);
    hoursField.setInputVerifier(verifier);
    minutesField.setInputVerifier(verifier);
    secondsField.setInputVerifier(verifier);

    delayField.setInputVerifier(verifier);

    toggleExpirationFieldEnabled();
    setSetupEnabled(isRunning);
}
项目:vbrowser    文件:AttrSchemeField.java   
protected void init()
{
    setInputVerifier(new InputVerifier()
    {
        public boolean verify(JComponent input)
        {
            if (!(input instanceof AttrSchemeField))
                return true; // give up focus
            return ((AttrSchemeField) input).isEditValid();
        }
    });
}
项目:vbrowser    文件:AttrPortField.java   
protected void init()
{
    setInputVerifier(new InputVerifier()
    {
        public boolean verify(JComponent input)
        {
            if (!(input instanceof AttrIntField))
                return true; // give up focus
            return ((AttrPortField) input).isEditValid();
        }
    });
}
项目:vbrowser    文件:AttrIntField.java   
protected void init()
{
    setInputVerifier(new InputVerifier()
    {
        public boolean verify(JComponent input)
        {
            if (!(input instanceof AttrIntField))
                return true; // give up focus
            return ((AttrIntField) input).isEditValid();
        }
    });
}
项目:vbrowser    文件:AttrSchemeField.java   
protected void init()
{
    setInputVerifier(new InputVerifier()
    {
        public boolean verify(JComponent input)
        {
            if (!(input instanceof AttrSchemeField))
                return true; // give up focus
            return ((AttrSchemeField) input).isEditValid();
        }
    });
}
项目:vbrowser    文件:AttrPortField.java   
protected void init()
{
    setInputVerifier(new InputVerifier()
    {
        public boolean verify(JComponent input)
        {
            if (!(input instanceof AttrIntField))
                return true; // give up focus
            return ((AttrPortField) input).isEditValid();
        }
    });
}
项目:vbrowser    文件:AttrIntField.java   
protected void init()
{
    setInputVerifier(new InputVerifier()
    {
        public boolean verify(JComponent input)
        {
            if (!(input instanceof AttrIntField))
                return true; // give up focus
            return ((AttrIntField) input).isEditValid();
        }
    });
}
项目:freecol    文件:SelectAmountDialog.java   
/**
 * The constructor to use.
 *
 * @param freeColClient The enclosing {@code FreeColClient}.
 * @param frame The owner frame.
 * @param goodsType The {@code GoodsType} to select an amount of.
 * @param available The amount of goods available.
 * @param defaultAmount The amount to select to start with.
 * @param pay If true, check the player has sufficient funds.
 */
public SelectAmountDialog(FreeColClient freeColClient, JFrame frame,
                          GoodsType goodsType, int available,
                          int defaultAmount, boolean pay) {
    super(freeColClient, frame);

    if (pay) {
        final Player player = getMyPlayer();
        final int gold = player.getGold();
        int price = player.getMarket().getCostToBuy(goodsType);
        available = Math.min(available, gold/price);
    }
    this.available = available;

    JTextArea question
        = Utility.localizedTextArea("selectAmountDialog.text");

    List<Integer> values = new ArrayList<>();
    int defaultIndex = -1;
    for (int index = 0; index < amounts.length; index++) {
        if (amounts[index] < available) {
            if (amounts[index] == defaultAmount) defaultIndex = index;
            values.add(amounts[index]);
        } else {
            if (available == defaultAmount) defaultIndex = index;
            values.add(available);
            break;
        }
    }
    if (defaultAmount > 0 && defaultIndex < 0) {
        for (int index = 0; index < values.size(); index++) {
            if (defaultAmount < values.get(index)) {
                values.add(index, defaultAmount);
                defaultIndex = index;
                break;
            }
        }
    }
    this.comboBox = new JComboBox<>(values.toArray(new Integer[0]));
    this.comboBox.setEditable(true);
    if (defaultIndex >= 0) this.comboBox.setSelectedIndex(defaultIndex);
    this.comboBox.setInputVerifier(new InputVerifier() {
            @Override @SuppressWarnings("unchecked")
            public boolean verify(JComponent input) {
                return verifyWholeBox((JComboBox<Integer>)input);
            }
        });
    MigPanel panel = new MigPanel(new MigLayout("wrap 1", "", ""));
    panel.add(question);
    panel.add(this.comboBox, "wrap 20, growx");
    panel.setSize(panel.getPreferredSize());

    initializeInputDialog(frame, true, panel, null, "ok", "cancel");
}
项目:FreeCol    文件:SelectAmountDialog.java   
/**
 * The constructor to use.
 *
 * @param freeColClient The enclosing {@code FreeColClient}.
 * @param frame The owner frame.
 * @param goodsType The {@code GoodsType} to select an amount of.
 * @param available The amount of goods available.
 * @param defaultAmount The amount to select to start with.
 * @param pay If true, check the player has sufficient funds.
 */
public SelectAmountDialog(FreeColClient freeColClient, JFrame frame,
                          GoodsType goodsType, int available,
                          int defaultAmount, boolean pay) {
    super(freeColClient, frame);

    if (pay) {
        final Player player = getMyPlayer();
        final int gold = player.getGold();
        int price = player.getMarket().getCostToBuy(goodsType);
        available = Math.min(available, gold/price);
    }
    this.available = available;

    JTextArea question
        = Utility.localizedTextArea("selectAmountDialog.text");

    List<Integer> values = new ArrayList<>();
    int defaultIndex = -1;
    for (int index = 0; index < amounts.length; index++) {
        if (amounts[index] < available) {
            if (amounts[index] == defaultAmount) defaultIndex = index;
            values.add(amounts[index]);
        } else {
            if (available == defaultAmount) defaultIndex = index;
            values.add(available);
            break;
        }
    }
    if (defaultAmount > 0 && defaultIndex < 0) {
        for (int index = 0; index < values.size(); index++) {
            if (defaultAmount < values.get(index)) {
                values.add(index, defaultAmount);
                defaultIndex = index;
                break;
            }
        }
    }
    this.comboBox = new JComboBox<>(values.toArray(new Integer[0]));
    this.comboBox.setEditable(true);
    if (defaultIndex >= 0) this.comboBox.setSelectedIndex(defaultIndex);
    this.comboBox.setInputVerifier(new InputVerifier() {
            @Override @SuppressWarnings("unchecked")
            public boolean verify(JComponent input) {
                return verifyWholeBox((JComboBox<Integer>)input);
            }
        });
    MigPanel panel = new MigPanel(new MigLayout("wrap 1", "", ""));
    panel.add(question);
    panel.add(this.comboBox, "wrap 20, growx");
    panel.setSize(panel.getPreferredSize());

    initializeInputDialog(frame, true, panel, null, "ok", "cancel");
}
项目:alisma    文件:ReleveListeTable.java   
public CellEditor(InputVerifier verifier) {
    super(new JTextField());
    this.verifier = verifier;

}
项目:swingx    文件:NumberEditorExt.java   
/**
     * Creates and returns a JFormattedTextField configured with SwingX extended
     * NumberFormat and StrictNumberFormatter. This method is called if
     * the constructor parameter useStrictFormatter is true.
     * 
     * Use a static method so that we can do some stuff before calling the
     * superclass.
     */
    private static JFormattedTextField createFormattedTextFieldX(
            NumberFormat format) {
       StrictNumberFormatter formatter = new StrictNumberFormatter(
                new NumberFormatExt(format));
        final JFormattedTextField textField = new JFormattedTextField(
                formatter);
        /*
         * FIXME: I am sure there is a better way to do this, but I don't know
         * what it is. JTable sets up a binding for the ESCAPE key, but
         * JFormattedTextField overrides that binding with it's own. Remove the
         * JFormattedTextField binding.
         */
        InputMap map = textField.getInputMap();
        map.put(KeyStroke.getKeyStroke("ESCAPE"), "none");
//        while (map != null) {
//            map.remove(KeyStroke.getKeyStroke("pressed ESCAPE"));
//            map = map.getParent();
//        }
        /*
         * Set an input verifier to prevent the cell losing focus when the value
         * is invalid
         */
        textField.setInputVerifier(new InputVerifier() {
            @Override
            public boolean verify(JComponent input) {
                JFormattedTextField ftf = (JFormattedTextField) input;
                return ftf.isEditValid();
            }
        });
        /*
         * The formatted text field will not call stopCellEditing() until the
         * value is valid. So do the red border thing here.
         */
        textField.addPropertyChangeListener("editValid",
                new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getNewValue() == Boolean.TRUE) {
                    ((JFormattedTextField) evt.getSource())
                    .setBorder(new LineBorder(Color.black));
                } else {
                    ((JFormattedTextField) evt.getSource())
                    .setBorder(new LineBorder(Color.red));
                }
            }
        });
        return textField;
    }
项目:swingx    文件:NumberEditorExt.java   
/**
     * Creates and returns a JFormattedTextField configured with defaults. This
     * method is called if the contructor useStrictFormatter is false.<p> 
     * 
     * Use a static method so that we can do some stuff before calling the
     * superclass.
     */
    private static JFormattedTextField createFormattedTextField(
            NumberFormat formatter) {
        final JFormattedTextField textField = new JFormattedTextField(
                new NumberFormatExt(formatter));
        /*
         * FIXME: I am sure there is a better way to do this, but I don't know
         * what it is. JTable sets up a binding for the ESCAPE key, but
         * JFormattedTextField overrides that binding with it's own. Remove the
         * JFormattedTextField binding.
         */
        InputMap map = textField.getInputMap();
        map.put(KeyStroke.getKeyStroke("ESCAPE"), "none");
//        while (map != null) {
//            map.remove(KeyStroke.getKeyStroke("pressed ESCAPE"));
//            map = map.getParent();
//        }
        /*
         * Set an input verifier to prevent the cell losing focus when the value
         * is invalid
         */
        textField.setInputVerifier(new InputVerifier() {
            @Override
            public boolean verify(JComponent input) {
                JFormattedTextField ftf = (JFormattedTextField) input;
                return ftf.isEditValid();
            }
        });
        /*
         * The formatted text field will not call stopCellEditing() until the
         * value is valid. So do the red border thing here.
         */
        textField.addPropertyChangeListener("editValid",
                new PropertyChangeListener() {
                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                        if (evt.getNewValue() == Boolean.TRUE) {
                            ((JFormattedTextField) evt.getSource())
                                    .setBorder(new LineBorder(Color.black));
                        } else {
                            ((JFormattedTextField) evt.getSource())
                                    .setBorder(new LineBorder(Color.red));
                        }
                    }
                });
        return textField;
    }
项目:metasfresh    文件:CTextPane.java   
/**
 *  Set Input Verifier
 *  @param l verifyer
 */
@Override
public void setInputVerifier (InputVerifier l)
{
    m_textPane.setInputVerifier(l);
}
项目:metasfresh    文件:CTextArea.java   
/**
 *  Set Text Input Verifier
 *  @param l
 */
@Override
public void setInputVerifier (InputVerifier l)
{
    m_textArea.setInputVerifier(l);
}
项目:JBroTable    文件:JBroTableHeader.java   
@Override
public InputVerifier getInputVerifier() {
  return JBroTableHeader.this.getInputVerifier();
}
项目:JBroTable    文件:JBroTableHeader.java   
@Override
public void setInputVerifier( InputVerifier inputVerifier ) {
  JBroTableHeader.this.setInputVerifier( inputVerifier );
}
项目:aibench-project    文件:NumberEditorExt.java   
/**
 * Use a static method so that we can do some stuff before calling the
 * superclass.
 */
private static JFormattedTextField createFormattedTextField(
        NumberFormat formatter) {
    final JFormattedTextField textField = new JFormattedTextField(
            new NumberEditorNumberFormat(formatter));
    /*
     * FIXME: I am sure there is a better way to do this, but I don't know
     * what it is. JTable sets up a binding for the ESCAPE key, but
     * JFormattedTextField overrides that binding with it's own. Remove the
     * JFormattedTextField binding.
     */
    InputMap map = textField.getInputMap();
    while (map != null) {
        map.remove(KeyStroke.getKeyStroke("pressed ESCAPE"));
        map = map.getParent();
    }
    /*
     * Set an input verifier to prevent the cell losing focus when the value
     * is invalid
     */
    textField.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            JFormattedTextField ftf = (JFormattedTextField) input;
            return ftf.isEditValid();
        }
    });
    /*
     * The formatted text field will not call stopCellEditing() until the
     * value is valid. So do the red border thing here.
     */
    textField.addPropertyChangeListener("editValid",
            new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getNewValue() == Boolean.TRUE) {
                        ((JFormattedTextField) evt.getSource())
                                .setBorder(new LineBorder(Color.black));
                    } else {
                        ((JFormattedTextField) evt.getSource())
                                .setBorder(new LineBorder(Color.red));
                    }
                }
            });
    return textField;
}
项目:freeVM    文件:InstrumentedAbstractButton.java   
public InputVerifier getInputVerifier() {
    InstrumentedUILog.add(new Object[] { "JComponent.getInputVerifier" });
    return super.getInputVerifier();
}
项目:freeVM    文件:InstrumentedAbstractButton.java   
public void setInputVerifier(InputVerifier arg0) {
    InstrumentedUILog.add(new Object[] { "JComponent.setInputVerifier" });
    super.setInputVerifier(arg0);
}
项目:freeVM    文件:InstrumentedJTextComponent.java   
public InputVerifier getInputVerifier() {
    InstrumentedUILog
            .add(new Object[] { "JTextComponent.getInputVerifier" });
    return super.getInputVerifier();
}
项目:freeVM    文件:InstrumentedJTextComponent.java   
public void setInputVerifier(InputVerifier arg0) {
    InstrumentedUILog.add(new Object[] { "JTextComponent.setInputVerifier",
            arg0 });
    super.setInputVerifier(arg0);
}
项目:freeVM    文件:InstrumentedJComponent.java   
public InputVerifier getInputVerifier() {
    InstrumentedUILog.add(new Object[] { "getInputVerifier" });
    return super.getInputVerifier();
}
项目:freeVM    文件:InstrumentedJComponent.java   
public void setInputVerifier(InputVerifier arg0) {
    InstrumentedUILog.add(new Object[] { "setInputVerifier", arg0 });
    super.setInputVerifier(arg0);
}
项目:freeVM    文件:InstrumentedJTextField.java   
public InputVerifier getInputVerifier() {
    InstrumentedUILog.add(new Object[] { "getInputVerifier" });
    return super.getInputVerifier();
}
项目:freeVM    文件:InstrumentedJTextField.java   
public void setInputVerifier(InputVerifier arg0) {
    InstrumentedUILog.add(new Object[] { "setInputVerifier", arg0 });
    super.setInputVerifier(arg0);
}
项目:freeVM    文件:InstrumentedJTextArea.java   
public InputVerifier getInputVerifier() {
    InstrumentedUILog.add(new Object[] { "getInputVerifier" });
    return super.getInputVerifier();
}
项目:freeVM    文件:InstrumentedJTextArea.java   
public void setInputVerifier(InputVerifier arg0) {
    InstrumentedUILog.add(new Object[] { "setInputVerifier", arg0 });
    super.setInputVerifier(arg0);
}
项目:freeVM    文件:InstrumentedJButton.java   
public InputVerifier getInputVerifier() {
    InstrumentedUILog.add(new Object[] { "JComponent.getInputVerifier" });
    return super.getInputVerifier();
}
项目:freeVM    文件:InstrumentedJButton.java   
public void setInputVerifier(InputVerifier arg0) {
    InstrumentedUILog.add(new Object[] { "JComponent.setInputVerifier" });
    super.setInputVerifier(arg0);
}
项目:freedots    文件:EditFingeringAction.java   
FingeringEditor() {
  super(gui, "Fingering", true);

  JPanel fingerPanel = new JPanel(new BorderLayout());
  JLabel label = new JLabel("Fingering: ");
  label.setDisplayedMnemonic(KeyEvent.VK_F);
  text = new JTextField();
  InputVerifier verifier = new InputVerifier() {
      public boolean verify(JComponent input) {
        final JTextComponent source = (JTextComponent) input;
        String text = source.getText();
        return text.length() == 0 || text.matches("[1-5-]+");
      }
    };
  text.setInputVerifier(verifier);
  label.setLabelFor(text);
  fingerPanel.add(label, BorderLayout.WEST);
  fingerPanel.add(text, BorderLayout.CENTER);

  okButton =
    new JButton(UIManager.getString("OptionPane.okButtonText",
                                    getLocale()));
  okButton.addActionListener(this);

  cancelButton =
    new JButton(UIManager.getString("OptionPane.cancelButtonText",
                                    getLocale()));
  cancelButton.addActionListener(this);

  JPanel buttonPane = new JPanel();
  buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
  buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
  buttonPane.add(Box.createHorizontalGlue());
  buttonPane.add(cancelButton);
  buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
  buttonPane.add(okButton);

  Container contentPane = getContentPane();
  contentPane.add(fingerPanel, BorderLayout.CENTER);
  contentPane.add(buttonPane, BorderLayout.PAGE_END);

  getRootPane().setDefaultButton(okButton);

  pack();
  setLocationRelativeTo(gui);
}