当前位置: 首页>>代码示例>>Java>>正文


Java InputVerifier类代码示例

本文整理汇总了Java中javax.swing.InputVerifier的典型用法代码示例。如果您正苦于以下问题:Java InputVerifier类的具体用法?Java InputVerifier怎么用?Java InputVerifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InputVerifier类属于javax.swing包,在下文中一共展示了InputVerifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initInputVerifiers

import javax.swing.InputVerifier; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RevertModifications.java

示例2: CommObjectTable

import javax.swing.InputVerifier; //导入依赖的package包/类
/**
 * 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);
    
    
}
 
开发者ID:KONNEKTING,项目名称:KonnektingSuite,代码行数:22,代码来源:CommObjectTable.java

示例3: getGaTableCellEditor

import javax.swing.InputVerifier; //导入依赖的package包/类
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;
}
 
开发者ID:KONNEKTING,项目名称:KonnektingSuite,代码行数:24,代码来源:CommObjectTable.java

示例4: callUpdateIfReady

import javax.swing.InputVerifier; //导入依赖的package包/类
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();
		}						
	}
}
 
开发者ID:DistantEye,项目名称:EP_Utilities,代码行数:20,代码来源:TextChangeListener.java

示例5: makeTextField

import javax.swing.InputVerifier; //导入依赖的package包/类
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;
}
 
开发者ID:GideonLeGrange,项目名称:panstamp-tools,代码行数:19,代码来源:PanStampParamDialog.java

示例6: setup

import javax.swing.InputVerifier; //导入依赖的package包/类
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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:CheckoutStep.java

示例7: interactiveNumberInputVerifier

import javax.swing.InputVerifier; //导入依赖的package包/类
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, "");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:34,代码来源:NumberEditorExtTest.java

示例8: AttackOverviewGui

import javax.swing.InputVerifier; //导入依赖的package包/类
/**
 * 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;
        }
    });
}
 
开发者ID:RUB-NDS,项目名称:OpenID-Attacker,代码行数:37,代码来源:AttackOverviewGui.java

示例9: buildInputVerifier

import javax.swing.InputVerifier; //导入依赖的package包/类
private InputVerifier buildInputVerifier() {
    return new InputVerifier() {
        @Override
        public boolean verify(JComponent component) {
            return isValid(parseDecimalText());
        }
    };
}
 
开发者ID:objektwerks,项目名称:swing,代码行数:9,代码来源:RangeBoundedDecimalTextField.java

示例10: shouldYieldFocus

import javax.swing.InputVerifier; //导入依赖的package包/类
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;
}
 
开发者ID:sogeti-java-nl,项目名称:masters-of-java-software,代码行数:16,代码来源:TeamProfileListManager.java

示例11: PingerPanel

import javax.swing.InputVerifier; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:40,代码来源:PingerPanel.java

示例12: init

import javax.swing.InputVerifier; //导入依赖的package包/类
protected void init()
{
    setInputVerifier(new InputVerifier()
    {
        public boolean verify(JComponent input)
        {
            if (!(input instanceof AttrSchemeField))
                return true; // give up focus
            return ((AttrSchemeField) input).isEditValid();
        }
    });
}
 
开发者ID:NLeSC,项目名称:vbrowser,代码行数:13,代码来源:AttrSchemeField.java

示例13: init

import javax.swing.InputVerifier; //导入依赖的package包/类
protected void init()
{
    setInputVerifier(new InputVerifier()
    {
        public boolean verify(JComponent input)
        {
            if (!(input instanceof AttrIntField))
                return true; // give up focus
            return ((AttrPortField) input).isEditValid();
        }
    });
}
 
开发者ID:NLeSC,项目名称:vbrowser,代码行数:13,代码来源:AttrPortField.java

示例14: init

import javax.swing.InputVerifier; //导入依赖的package包/类
protected void init()
{
    setInputVerifier(new InputVerifier()
    {
        public boolean verify(JComponent input)
        {
            if (!(input instanceof AttrIntField))
                return true; // give up focus
            return ((AttrIntField) input).isEditValid();
        }
    });
}
 
开发者ID:NLeSC,项目名称:vbrowser,代码行数:13,代码来源:AttrIntField.java

示例15: SelectAmountDialog

import javax.swing.InputVerifier; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:64,代码来源:SelectAmountDialog.java


注:本文中的javax.swing.InputVerifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。