FilterEditor<MatchVariableConstraint> () { return new FilterEditor<>(myTable.getMatchVariable(), myTable.getConstraintChangedCallback()) { private final IntegerField myMinField = new IntegerField(); private final IntegerField myMaxField = new IntegerField(); private final JLabel myMinLabel = new JLabel(SSRBundle.message("min.label")); private final JLabel myMaxLabel = new JLabel(SSRBundle.message("max.label")); @Override protected void layoutComponents() { final GroupLayout layout = new GroupLayout(this); setLayout(layout); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout.createSequentialGroup() .addComponent(myMinLabel) .addComponent(myMinField) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 20, 20) .addComponent(myMaxLabel) .addComponent(myMaxField) ); layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(myMinLabel) .addComponent(myMinField) .addComponent(myMaxLabel) .addComponent(myMaxField) ); myMinField.getValueEditor().addListener(newValue -> { if (myMinField.getValueEditor().isValid(newValue) && myMaxField.getValue() < newValue) myMaxField.setValue(newValue); }); myMaxField.getValueEditor().addListener(newValue -> { if (myMaxField.getValueEditor().isValid(newValue) && myMinField.getValue() > newValue) myMinField.setValue(newValue); }); } @Override protected void loadValues() { myMinField.setMinValue(myMinZero ? 0 : 1); myMinField.setMaxValue(myMaxUnlimited ? Integer.MAX_VALUE : 1); myMinField.setDefaultValue(myMinZero ? 0 : 1); myMinField.setDefaultValueText(myMinZero ? "0" : "1"); final int minCount = myConstraint.getMinCount(); if (!isDefaultValue(minCount)) { myMinField.setValue(minCount); } myMinField.setCanBeEmpty(true); myMinField.selectAll(); myMaxField.setMinValue(myMinZero ? 0 : 1); myMaxField.setMaxValue(myMaxUnlimited ? Integer.MAX_VALUE : 1); myMaxField.setDefaultValue(myMaxUnlimited ? Integer.MAX_VALUE : 1); myMaxField.setDefaultValueText(myMaxUnlimited ? SSRBundle.message("unlimited.placeholder") : "1"); final int maxCount = myConstraint.getMaxCount(); if (!isDefaultValue(maxCount)) { myMaxField.setValue(maxCount); } myMaxField.setCanBeEmpty(true); myMaxField.selectAll(); } private boolean isDefaultValue(int count) { if (count == 0) { return myMinZero; } else if (count == 1) { return !myMinZero || !myMaxUnlimited; } else if (count == Integer.MAX_VALUE) { return myMaxUnlimited; } return false; } @Override public void saveValues() { myConstraint.setMinCount(myMinField.getValue()); myConstraint.setMaxCount(myMaxField.getValue()); } @Override public JComponent getPreferredFocusedComponent() { return myMinField; } @Override public JComponent[] getFocusableComponents() { return new IntegerField[]{myMinField, myMaxField}; } }; }