private JPanel buildMiscPanel() { FormLayout layout = new FormLayout( "right:max(50dlu;pref), 3dlu, 50dlu, 3dlu, 50dlu", "p, 3dlu, p, 3dlu, p, 3dlu, p"); layout.setRowGroups(new int[][] {{1, 3, 5}}); PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder(); Action chooseAction = new ChooseColorAction( builder.getPanel(), presentationModel.getModel(ExampleBean.PROPERTYNAME_COLOR)); CellConstraints cc = new CellConstraints(); builder.addLabel("JCheckBox", cc.xy(1, 1)); builder.add(checkBox, cc.xy(3, 1)); builder.addLabel("JSlider", cc.xy(1, 3)); builder.add(slider, cc.xy(3, 3)); builder.add(floatLabel, cc.xy(5, 3)); builder.addLabel("JSpinner", cc.xy(1, 5)); builder.add(spinner, cc.xy(3, 5)); builder.addLabel("JColorChooser", cc.xy(1, 7)); builder.add(colorPreview, cc.xy(3, 7, "fill, fill")); builder.add(new JButton(chooseAction), cc.xy(5, 7, "left, center")); return builder.getPanel(); }
private void initEventHandling() { presentationModel .getModel(ExampleBean.PROPERTYNAME_COLOR) .addValueChangeListener(new ColorUpdateHandler()); }
private void updatePreviewPanel() { colorPreview.setBackground(((ExampleBean) presentationModel.getBean()).getColor()); }
/** * 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 }