public void testJColorChooser() throws Exception { assertSame(DefaultColorSelectionModel.class, ch.getSelectionModel().getClass()); assertNull(ch.accessibleContext); assertEquals(Color.WHITE, ch.getColor()); ch = new JColorChooser(Color.BLACK); assertEquals(Color.BLACK, ch.getColor()); ColorSelectionModel model = new DefaultColorSelectionModel(); ch = new JColorChooser(model); assertFalse(propertyChangeController.isChanged()); assertSame(model, ch.getSelectionModel()); assertSame(BorderLayout.class, ch.getLayout().getClass()); }
public void testSetGetSelectionModel() throws Exception { assertNotNull(ch.getSelectionModel()); ColorSelectionModel oldModel = ch.getSelectionModel(); ColorSelectionModel model = new DefaultColorSelectionModel(); ch.setSelectionModel(model); assertTrue(propertyChangeController.isChanged(JColorChooser.SELECTION_MODEL_PROPERTY)); assertSame(model, ((PropertyChangeEvent) propertyChangeController.getLastEvent()) .getNewValue()); assertSame(oldModel, ((PropertyChangeEvent) propertyChangeController.getLastEvent()) .getOldValue()); ch.setSelectionModel(null); assertNull(ch.getSelectionModel()); }
public void testInstallUninstallListeners() throws Exception { ui.uninstallListeners(); int propChangeListCount = ch.getPropertyChangeListeners().length; int changeListcount = ((DefaultColorSelectionModel) ch.getSelectionModel()) .getChangeListeners().length; ui.installListeners(); assertEquals(propChangeListCount + 1, ch.getPropertyChangeListeners().length); assertEquals(changeListcount + 1, ((DefaultColorSelectionModel) ch.getSelectionModel()) .getChangeListeners().length); ui.uninstallListeners(); assertEquals(propChangeListCount, ch.getPropertyChangeListeners().length); assertEquals(changeListcount, ((DefaultColorSelectionModel) ch.getSelectionModel()) .getChangeListeners().length); }
/** * This method creates a new JColorChooser with the default initial color. */ public JColorChooser() { this(new DefaultColorSelectionModel()); }
public CColorChooser() { this(new DefaultColorSelectionModel(Color.WHITE), null); }
public CColorChooser(final Color initialColor) { this(new DefaultColorSelectionModel(initialColor), null); }
public CColorChooser(final Color initialColor, final Color[] recentColors) { this(new DefaultColorSelectionModel(initialColor), recentColors); }
public JColorChooser() { this(new DefaultColorSelectionModel(Color.WHITE)); }
public JColorChooser(Color initialColor) { this(new DefaultColorSelectionModel(initialColor)); }
public void stateChanged(ChangeEvent arg0) { DefaultColorSelectionModel cc = (DefaultColorSelectionModel)arg0.getSource(); this.color = cc.getSelectedColor(); }
/** * This method creates a new JColorChooser with the given initial color. * * @param initial The initial color. */ public JColorChooser(Color initial) { this(new DefaultColorSelectionModel(initial)); }