本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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();
}
}
}
示例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;
}
示例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());
}
示例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, "");
}
示例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;
}
});
}
示例9: buildInputVerifier
import javax.swing.InputVerifier; //导入依赖的package包/类
private InputVerifier buildInputVerifier() {
return new InputVerifier() {
@Override
public boolean verify(JComponent component) {
return isValid(parseDecimalText());
}
};
}
示例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;
}
示例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);
}
示例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();
}
});
}
示例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();
}
});
}
示例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();
}
});
}
示例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");
}