List of usage examples for com.jgoodies.forms.factories DefaultComponentFactory DefaultComponentFactory
DefaultComponentFactory
From source file:edu.udo.scaffoldhunter.view.scaffoldtree.config.GradientPanel.java
License:Open Source License
/** * Create a new gradient panel/*from www. j ava 2s.c om*/ * * @param color * should the panel provide color selection? * @param mapping * the mapping whose gradient is configured by this panel */ public GradientPanel(boolean color, ConfigMapping mapping) { super(new FormLayout("p, 3dlu, max(20dlu;p), p:g", "p:g, p, 3dlu, p, 3dlu, p, 5dlu, p, 3dlu, max(20dlu;p), 3dlu, max(20dlu;p), p:g")); this.mapping = mapping; DefaultComponentFactory componentFactory = new DefaultComponentFactory(); ButtonGroup bg = new ButtonGroup(); JRadioButton ascending = new JRadioButton(I18n.get("VisualMappings.Gradient.Ascending")); ascending.setActionCommand(ASCENDING); ascending.addActionListener(this); bg.add(ascending); JRadioButton descending = new JRadioButton(I18n.get("VisualMappings.Gradient.Descending")); descending.setActionCommand(DESCENDING); descending.addActionListener(this); bg.add(descending); ascending.setSelected(mapping.isGradientAscending()); descending.setSelected(!mapping.isGradientAscending()); add(componentFactory.createSeparator(I18n.get("VisualMappings.Direction")), CC.xyw(1, 2, 4)); add(ascending, CC.xyw(1, 4, 4)); add(descending, CC.xyw(1, 6, 4)); if (color) { add(componentFactory.createSeparator(I18n.get("VisualMappings.Color")), CC.xyw(1, 8, 4)); add(new JLabel(I18n.get("VisualMappings.Gradient.Color1") + ":"), CC.xy(1, 10)); ColorEditor ce1 = new ColorEditor(mapping.getGradientColor1()); ce1.addPropertyChangeListener(ColorEditor.COLOR_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { GradientPanel.this.mapping.setGradientColor1((Color) evt.getNewValue()); } }); add(ce1, CC.xy(3, 10)); add(new JLabel(I18n.get("VisualMappings.Gradient.Color2") + ":"), CC.xy(1, 12)); ColorEditor ce2 = new ColorEditor(mapping.getGradientColor2()); ce2.addPropertyChangeListener(ColorEditor.COLOR_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { GradientPanel.this.mapping.setGradientColor2((Color) evt.getNewValue()); } }); add(ce2, CC.xy(3, 12)); } }