Example #1
0
 private void updatePreviewPanel() {
   colorPreview.setBackground(((ExampleBean) presentationModel.getBean()).getColor());
 }
Example #2
0
  /**
   * Creates, binds and configures the UI components.
   *
   * <p>If possible, the components are created using the BasicComponentFactory, or the Bindings
   * class.
   */
  private void initComponents() {
    // Text Components
    textField =
        BasicComponentFactory.createTextField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_TEXT));
    textArea =
        BasicComponentFactory.createTextArea(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_TEXT));
    passwordField =
        BasicComponentFactory.createPasswordField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_TEXT));
    textLabel =
        BasicComponentFactory.createLabel(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_TEXT));

    // Formatted Input
    dateField =
        BasicComponentFactory.createDateField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_DATE));
    integerField =
        BasicComponentFactory.createIntegerField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_INT_VALUE));
    longField =
        BasicComponentFactory.createLongField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_LONG_VALUE));

    // Choice
    ValueModel intChoiceModel = presentationModel.getModel(ExampleBean.PROPERTYNAME_INT_CHOICE);
    leftIntRadio =
        BasicComponentFactory.createRadioButton(intChoiceModel, ExampleBean.LEFT_INTEGER, "Left");
    centerIntRadio =
        BasicComponentFactory.createRadioButton(
            intChoiceModel, ExampleBean.CENTER_INTEGER, "Center");
    rightIntRadio =
        BasicComponentFactory.createRadioButton(intChoiceModel, ExampleBean.RIGHT_INTEGER, "Right");
    alignmentIntCombo =
        BasicComponentFactory.createComboBox(
            new SelectionInList(ExampleBean.INTEGER_CHOICES, intChoiceModel));

    ValueModel objectChoiceModel =
        presentationModel.getModel(ExampleBean.PROPERTYNAME_OBJECT_CHOICE);
    leftObjectRadio =
        BasicComponentFactory.createRadioButton(objectChoiceModel, ExampleBean.LEFT, "Left");
    centerObjectRadio =
        BasicComponentFactory.createRadioButton(objectChoiceModel, ExampleBean.CENTER, "Center");
    rightObjectRadio =
        BasicComponentFactory.createRadioButton(objectChoiceModel, ExampleBean.RIGHT, "Right");
    alignmentObjectCombo =
        BasicComponentFactory.createComboBox(
            new SelectionInList(ExampleBean.OBJECT_CHOICES, objectChoiceModel));

    // Lists
    comboBox =
        BasicComponentFactory.createComboBox(
            presentationModel.getSelectionInList(), TutorialUtils.createAlbumListCellRenderer());

    list =
        BasicComponentFactory.createList(
            presentationModel.getSelectionInList(), TutorialUtils.createAlbumListCellRenderer());

    table = new JTable();
    table.setModel(TutorialUtils.createAlbumTableModel(presentationModel.getSelectionInList()));
    table.setSelectionModel(
        new SingleListSelectionAdapter(
            presentationModel.getSelectionInList().getSelectionIndexHolder()));

    // Misc
    checkBox =
        BasicComponentFactory.createCheckBox(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_BOOLEAN_VALUE), "available");
    colorPreview = new JPanel();
    colorPreview.setBorder(new LineBorder(Color.GRAY));
    updatePreviewPanel();

    ValueModel floatModel = presentationModel.getModel(ExampleBean.PROPERTYNAME_FLOAT_VALUE);
    slider = new JSlider();
    slider.setModel(
        new BoundedRangeAdapter(
            ConverterFactory.createFloatToIntegerConverter(floatModel, 100), 0, 0, 100));
    floatLabel =
        BasicComponentFactory.createLabel(
            ConverterFactory.createStringConverter(floatModel, NumberFormat.getPercentInstance()));
    spinner = new JSpinner();
    spinner.setModel(
        SpinnerAdapterFactory.createNumberAdapter(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_INT_LIMITED),
            0, // defaultValue
            0, // minValue
            100, // maxValue
            5)); // step
  }