本文整理汇总了Java中javax.swing.colorchooser.ColorSelectionModel类的典型用法代码示例。如果您正苦于以下问题:Java ColorSelectionModel类的具体用法?Java ColorSelectionModel怎么用?Java ColorSelectionModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColorSelectionModel类属于javax.swing.colorchooser包,在下文中一共展示了ColorSelectionModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:valsr,项目名称:SweetHome3D,代码行数:20,代码来源:ColorButton.java
示例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();
}
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:38,代码来源:ColorButton.java
示例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));
}
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:8,代码来源:SwingObservable.java
示例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);
}
}
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:13,代码来源:ChangeEventColorObservable.java
示例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();
}
}));
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:JColorChooserOperator.java
示例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);
}
});
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:JColorChooserOperator.java
示例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());
}
}
开发者ID:google,项目名称:binnavi,代码行数:16,代码来源:CColorChooser.java
示例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());
}
开发者ID:d2fn,项目名称:passage,代码行数:10,代码来源:OMColorChooser.java
示例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());
}
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:JColorChooserTest.java
示例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());
}
开发者ID:shannah,项目名称:cn1,代码行数:14,代码来源:JColorChooserTest.java
示例11: setSelectionModel
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
@Override
public void setSelectionModel(ColorSelectionModel newModel) {
AlfaColorSelectionModel model = (AlfaColorSelectionModel) newModel;
super.setSelectionModel(model);
registerListenerToModel();
model.fireStateChanged();
}
开发者ID:Danstahr,项目名称:Geokuk,代码行数:8,代码来源:JAlfaColorChooser.java
示例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);
}
}
开发者ID:projectestac,项目名称:jclic,代码行数:16,代码来源:AlphaColorChooserPanel.java
示例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]);
}
}
}
开发者ID:VanetSim,项目名称:VanetSim,代码行数:18,代码来源:StreetsJColorChooserPanel.java
示例14: ChangeEventColorObservable
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
ChangeEventColorObservable(ColorSelectionModel widget) {
this.widget = widget;
}
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:4,代码来源:ChangeEventColorObservable.java
示例15: ChangeEventConsumer
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
ChangeEventConsumer(Observer<? super ChangeEvent> actual, ColorSelectionModel widget) {
super(actual, widget);
}
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:4,代码来源:ChangeEventColorObservable.java
示例16: onDispose
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
@Override
protected void onDispose(ColorSelectionModel w) {
w.removeChangeListener(this);
}
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:5,代码来源:ChangeEventColorObservable.java
示例17: setRecentColors
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
private void setRecentColors(final ColorSelectionModel colorSelectionModel, UserPreferences preferences)
{
removeAll();
int i = 0;
if (UIManager.getLookAndFeel().getID().equals("GTK"))
{
// Add a label to replace the border that is not active
add(new JLabel(UIManager.getString("ColorChooser.previewText")), new GridBagConstraints(i++, 0, 1, 1, 0,
0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
}
List<Integer> recentColors = preferences.getRecentColors();
final int colorComponentSize = Math.round(20 * SwingTools.getResolutionScale());
for (int j = 0; j < recentColors.size() && j < MAX_COLORS; j++)
{
final Integer color = recentColors.get(j);
Component colorComponent = new JComponent()
{
@Override
protected void paintComponent(Graphics g)
{
Insets insets = getInsets();
int drawnWidth = getWidth() - insets.right - insets.left;
int drawnHeight = getHeight() - insets.bottom - insets.top;
g.setColor(Color.GRAY);
g.translate(insets.left, insets.top);
g.drawRect(0, 0, drawnWidth - 1, drawnHeight - 1);
g.setColor(new Color(color));
g.fillRect(1, 1, drawnWidth - 2, drawnHeight - 2);
}
@Override
public Dimension getPreferredSize()
{
return new Dimension(colorComponentSize, colorComponentSize);
}
};
colorComponent.addMouseListener(new MouseAdapter()
{
@Override
public void mousePressed(MouseEvent ev)
{
colorSelectionModel.setSelectedColor(new Color(color));
if (ev.getClickCount() == 2)
{
JRootPane rootPane = (JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class,
RecentColorsPanel.this);
if (rootPane != null)
{
for (JButton button : SwingTools.findChildren(rootPane, JButton.class))
{
if ("OK".equals(button.getActionCommand()))
{
button.doClick();
}
}
}
}
}
});
colorComponent.setCursor(this.pipetteCursor);
add(colorComponent, new GridBagConstraints(i++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
GridBagConstraints.NONE, new Insets(0, 0, 0, 2), 0, 0));
}
}
开发者ID:valsr,项目名称:SweetHome3D,代码行数:65,代码来源:ColorButton.java
示例18: JColorChooser
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
public JColorChooser(ColorSelectionModel model) {
colorSelectionModel = model;
setLayout(new BorderLayout());
updateUI();
}
开发者ID:shannah,项目名称:cn1,代码行数:6,代码来源:JColorChooser.java
示例19: getSelectionModel
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
public ColorSelectionModel getSelectionModel() {
return colorSelectionModel;
}
开发者ID:shannah,项目名称:cn1,代码行数:4,代码来源:JColorChooser.java
示例20: setSelectionModel
import javax.swing.colorchooser.ColorSelectionModel; //导入依赖的package包/类
public void setSelectionModel(ColorSelectionModel newModel) {
ColorSelectionModel oldModel = colorSelectionModel;
colorSelectionModel = newModel;
firePropertyChange(SELECTION_MODEL_PROPERTY, oldModel, newModel);
}
开发者ID:shannah,项目名称:cn1,代码行数:6,代码来源:JColorChooser.java
注:本文中的javax.swing.colorchooser.ColorSelectionModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论