예제 #1
0
 @Override
 public void setCount(String value) {
   boolean disabledEvents = disableEvents();
   try {
     countField.setText(value);
   } finally {
     if (disabledEvents) {
       enableEvents();
     }
   }
 }
예제 #2
0
  @Override
  protected void createComponents() {
    super.createComponents();

    Date initDate = DateUtils.currentDate();
    Date latestDate = initDate;
    Date earliestDate = DateUtils.earliestDate();

    entryDateLabel = new JLabel("Entry Date:");

    entryDateSpinnerModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.YEAR);
    entryDateSpinner = new JSpinner(entryDateSpinnerModel);
    entryDateSpinnerEditor = new JSpinner.DateEditor(entryDateSpinner, DateUtils.DATE_FORMAT);
    entryDateSpinner.setEditor(entryDateSpinnerEditor);
    entryDateSpinnerEditor
        .getTextField()
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {

              @Override
              public void changedUpdate(DocumentEvent e) {
                return;
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                processChange(e);
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                processChange(e);
              }

              private void processChange(DocumentEvent e) {
                if (eventsAreDisabled()) {
                  return;
                }
                if (entryDateSpinnerEditor.getTextField().hasFocus()) {
                  entryDateChanged();
                }
              }
            });
    //		entryDateSpinner.addChangeListener(new ChangeListener() {
    //			@Override
    //			public void stateChanged(ChangeEvent e) {
    //				if (eventsAreDisabled()) {
    //					return;
    //				}
    //				entryDateChanged();
    //			}
    //		});

    countLabel = new JLabel("Count:");

    countField = new JTextField(5);
    countField.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {
            return;
          }

          @Override
          public void keyReleased(KeyEvent e) {
            if (eventsAreDisabled()) {
              return;
            }
            countChanged();
          }

          @Override
          public void keyTyped(KeyEvent arg0) {
            return;
          }
        });
  }
예제 #3
0
 @Override
 public String getCount() {
   return countField.getText();
 }