本文整理汇总了Java中javax.swing.colorchooser.ColorSelectionModel类的典型用法代码示例。如果您正苦于以下问题:Java ColorSelectionModel类的具体用法?Java ColorSelectionModel怎么用?Java ColorSelectionModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColorSelectionModel类属于javax.swing.colorchooser包,在下文中一共展示了ColorSelectionModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RecentColorsPanel
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
private RecentColorsPanel(final ColorSelectionModel colorSelectionModel, final UserPreferences preferences)
{
super(new GridBagLayout());
this.pipetteCursor = SwingTools.createCustomCursor(
OperatingSystem.isMacOSX()
? ColorButton.class.getResource("resources/cursors/pipette16x16-macosx.png")
: ColorButton.class.getResource("resources/cursors/pipette16x16.png"),
ColorButton.class.getResource("resources/cursors/pipette32x32.png"), 0, 1, "Pipette",
Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
preferences.addPropertyChangeListener(UserPreferences.Property.RECENT_COLORS, new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent ev)
{
setRecentColors(colorSelectionModel, preferences);
}
});
setRecentColors(colorSelectionModel, preferences);
setOpaque(false);
}
示例2: ColorButton
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
/**
* Creates a new instance of ColorButton. Default color is black, default
* size of the icon is 16 x 16 pixels. This button is registered with itself
* for receiving action performed calls.
*/
public ColorButton() {
this.color = new Color(0, 0, 0);
this.iconHeight = 16;
this.iconWidth = 16;
this.colorChooserTitle = "Choose a Color";
//Set up the dialog that the button brings up.
colorChooser = new JColorChooser();
// replace the ugly and useless preview panel by an empty JPanel
colorChooser.setPreviewPanel(new JPanel());
// remove the swatch
AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels();
for (AbstractColorChooserPanel chooser : choosers) {
String clsName = chooser.getClass().getName();
if (clsName.equals("javax.swing.colorchooser.DefaultSwatchChooserPanel")) {
colorChooser.removeChooserPanel(chooser);
}
}
ColorSelectionModel colorSelectionModel = colorChooser.getSelectionModel();
colorSelectionModel.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent evt) {
ColorSelectionModel model = (ColorSelectionModel) evt.getSource();
setColor(model.getSelectedColor());
}
});
this.updateIcon();
}
示例3: change
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<ChangeEvent> change(@NonNull ColorSelectionModel component) {
ObjectHelper.requireNonNull(component, "component is null");
return RxSwingPlugins.onAssembly(new ChangeEventColorObservable(component));
}
示例4: subscribeActual
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
@Override
protected void subscribeActual(Observer<? super ChangeEvent> observer) {
ColorSelectionModel w = widget;
ChangeEventConsumer aec = new ChangeEventConsumer(observer, w);
observer.onSubscribe(aec);
w.addChangeListener(aec);
if (aec.get() == null) {
aec.onDispose(w);
}
}
示例5: getSelectionModel
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
/**
* Maps {@code JColorChooser.getSelectionModel()} through queue
*/
public ColorSelectionModel getSelectionModel() {
return (runMapping(new MapAction<ColorSelectionModel>("getSelectionModel") {
@Override
public ColorSelectionModel map() {
return ((JColorChooser) getSource()).getSelectionModel();
}
}));
}
示例6: setSelectionModel
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
/**
* Maps {@code JColorChooser.setSelectionModel(ColorSelectionModel)}
* through queue
*/
public void setSelectionModel(final ColorSelectionModel colorSelectionModel) {
runMapping(new MapVoidAction("setSelectionModel") {
@Override
public void map() {
((JColorChooser) getSource()).setSelectionModel(colorSelectionModel);
}
});
}
示例7: CColorChooser
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
public CColorChooser(final ColorSelectionModel model, final Color[] recentColors) {
super(model);
// Remove first chooser panel ("Swatches")
// TODO(cblichmann): Revisit this for JDK > 1.7
final AbstractColorChooserPanel[] panels = getChooserPanels();
if (panels.length > 0) {
removeChooserPanel(panels[0]);
}
m_recentColors = recentColors;
if (m_recentColors != null) {
addChooserPanel(new RecentColorsColorChooserPanel());
}
}
示例8: stateChanged
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
/**
* ChangeListener interface. Called when the color changes
*/
public void stateChanged(ChangeEvent e) {
if (!(e.getSource() instanceof ColorSelectionModel))
return;
setPreviewColor(((ColorSelectionModel) e.getSource()).getSelectedColor());
}
示例9: testJColorChooser
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
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());
}
示例10: testSetGetSelectionModel
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
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());
}
示例11: setSelectionModel
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
@Override
public void setSelectionModel(ColorSelectionModel newModel) {
AlfaColorSelectionModel model = (AlfaColorSelectionModel) newModel;
super.setSelectionModel(model);
registerListenerToModel();
model.fireStateChanged();
}
示例12: alphaSliderStateChanged
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
private void alphaSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_alphaSliderStateChanged
int v=alphaSlider.getValue();
alphaTxt.setText(Integer.toString(v));
ColorSelectionModel csm=getColorSelectionModel();
if(csm!=null){
Color c=csm.getSelectedColor();
Color nc = v < 255
? new Color(c.getRed(), c.getGreen(), c.getBlue(), v)
: new Color(c.getRed(), c.getGreen(), c.getBlue());
csm.setSelectedColor(nc);
}
}
示例13: itemStateChanged
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
/**
* An implemented <code>ItemListener</code> to change colors when user changes value in the <code>comboBox</code>.
*
* @param itemEvent the received event
*
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
*/
public void itemStateChanged(ItemEvent itemEvent) {
int state = itemEvent.getStateChange();
if (state == ItemEvent.SELECTED) {
int position = findColorLabel(itemEvent.getItem());
if (position != -1) {
ColorSelectionModel selectionModel = getColorSelectionModel();
selectionModel.setSelectedColor(COLORS[position]);
}
}
}
示例14: ChangeEventColorObservable
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
ChangeEventColorObservable(ColorSelectionModel widget) {
this.widget = widget;
}
示例15: ChangeEventConsumer
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
ChangeEventConsumer(Observer<? super ChangeEvent> actual, ColorSelectionModel widget) {
super(actual, widget);
}