Пример #1
0
  public MainCtrl(final StateManager stateManager) {
    this.view = new MainView(stateManager);

    this.view.getStateCombo().setModel(new DefaultComboBoxModel(State.values()));

    // change the state from new combo selection
    this.view
        .getStateCombo()
        .addItemListener(
            new ItemListener() {
              @Override
              public void itemStateChanged(ItemEvent event) {

                State item = (State) event.getItem();

                if (event.getStateChange() == ItemEvent.SELECTED) {
                  stateManager.update(item);
                }
              }
            });
  }