Package javax.swing

Examples of javax.swing.JColorChooser$AccessibleJColorChooser


import javax.swing.UIManager;

public class Test4887836 extends JApplet {
    public void init() {
        UIManager.put("Label.font", new Font("Perpetua", 0, 36)); // NON-NLS: property and font names
        add(new JColorChooser(Color.LIGHT_GRAY));
    }
View Full Code Here


public class Test4177735 implements Runnable {
    private static final long DELAY = 1000L;

    public static void main(String[] args) throws Exception {
        JColorChooser chooser = new JColorChooser();
        AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
        chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

        JDialog dialog = show(chooser);
        pause(DELAY);

        dialog.dispose();
View Full Code Here

import javax.swing.JButton;
import javax.swing.JColorChooser;

public class Test4461329 {
    public static void main(String[] args) {
        JColorChooser chooser = new JColorChooser();
        if (null == chooser.getPreviewPanel()) {
            throw new Error("Failed: getPreviewPanel() returned null");
        }
        JButton button = new JButton("Color"); // NON-NLS: simple label
        chooser.setPreviewPanel(button);
        if (button != chooser.getPreviewPanel()) {
            throw new Error("Failed in setPreviewPanel()");
        }
    }
View Full Code Here

public class Test4234761 implements PropertyChangeListener {
    private static final Color COLOR = new Color(51, 51, 51);

    public static void main(String[] args) {
        JColorChooser chooser = new JColorChooser(COLOR);
        JDialog dialog = Test4177735.show(chooser);

        PropertyChangeListener listener = new Test4234761();
        chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

        JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
        tabbedPane.setSelectedIndex(1); // HSB tab index

        if (!chooser.getColor().equals(COLOR)) {
            listener.propertyChange(null);
        }
        dialog.dispose();
    }
View Full Code Here

import java.util.Random;
import javax.swing.JColorChooser;

public class Test4165217 {
    public static void main(String[] args) {
        JColorChooser chooser = new JColorChooser();
        chooser.setColor(new Color(new Random().nextInt()));

        Color before = chooser.getColor();
        Color after = copy(chooser).getColor();

        if (!after.equals(before)) {
            throw new Error("color is changed after serialization");
        }
View Full Code Here

import javax.swing.JColorChooser;
import javax.swing.colorchooser.AbstractColorChooserPanel;

public class Test4711996 {
    public static void main(String[] args) {
        JColorChooser chooser = new JColorChooser();
        AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
        chooser.removeChooserPanel(panels[0]);
        chooser.updateUI();
    }
View Full Code Here

    }

    private static void test(Color[] colors) {
        JLabel label = new JLabel("Preview Panel"); // NON-NLS: simple label

        JColorChooser chooser = new JColorChooser();
        chooser.setPreviewPanel(label);

        float[] hsb = new float[3];
        for (int i = 0; i < colors.length; i++) {
            Color color = colors[i];
            // Make sure sure that there wasn't a regression
            // in java.awt.Color and the conversion methods
            Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);
            if (!color.equals(Color.getHSBColor(hsb[0], hsb[1], hsb[2]))) {
                throw new Error("color conversion is failed");
            }
            // 4193384 regression test
            if (!color.equals(new JColorChooser(color).getColor())) {
                throw new Error("constructor sets incorrect initial color");
            }
            // 4200976 regression test
            chooser.setColor(color);
            if (!color.equals(label.getForeground())) {
                throw new Error("a custom preview panel doesn't handle colors");
            }
        }
    }
View Full Code Here

    // set it up as the editor for all Color cells.
    final ColorEditor colorEditor = new ColorEditor(button);
    table.setDefaultEditor(Color.class, colorEditor);

    // Set up the dialog that the button brings up.
    final JColorChooser colorChooser = new JColorChooser();

    // AbstractColorChooserPanel panels[] = colorChooser.getChooserPanels();

    // The following has the effect of removing the RGB panel and making the HSB panel the default:

    // AbstractColorChooserPanel preferredPanels[] = new AbstractColorChooserPanel[2];
    // preferredPanels[0] = panels[1];
    // preferredPanels[1] = panels[0];
    // colorChooser.setChooserPanels(preferredPanels);

    ActionListener okListener = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        colorEditor.currentColor = colorChooser.getColor();
        Color newColor = colorEditor.currentColor;
        StyleMapEntry entry = (StyleMapEntry) styleList.get(tbl.getSelectedRow());
        int column = tbl.getSelectedColumn();
        if (column == StyleConstants.BG_COLUMN)
          entry.setBackground(newColor);
        else
          entry.setForeground(newColor);

        tbl.repaint();
      }
    };
    final JDialog dialog = JColorChooser.createDialog(button, "Pick a Color", true, colorChooser,
            okListener, null);

    // Here's the code that brings up the dialog.
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        button.setBackground(colorEditor.currentColor);
        colorChooser.setColor(colorEditor.currentColor);
        // Without the following line, the dialog comes up
        // in the middle of the screen.
        dialog.setLocationRelativeTo(button);
        dialog.show();
      }
View Full Code Here

        colorEdit = new JButton(tr("Choose"));
        colorEdit.addActionListener(new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent e) {
                int sel = colors.getSelectedRow();
                JColorChooser chooser = new JColorChooser((Color)colors.getValueAt(sel, 1));
                int answer = JOptionPane.showConfirmDialog(
                        gui, chooser,
                        tr("Choose a color for {0}", getName((String)colors.getValueAt(sel, 0))),
                        JOptionPane.OK_CANCEL_OPTION,
                        JOptionPane.PLAIN_MESSAGE);
                if (answer == JOptionPane.OK_OPTION) {
                    colors.setValueAt(chooser.getColor(), sel, 1);
                }
            }
        });
        defaultSet = new JButton(tr("Set to default"));
        defaultSet.addActionListener(new ActionListener(){
View Full Code Here

        this.btnFadeColor = new JButton();

        this.btnFadeColor.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JColorChooser chooser = new JColorChooser(btnFadeColor.getBackground());
                int answer = JOptionPane.showConfirmDialog(
                        CommonSettingsPanel.this, chooser,
                        tr("Choose a color for {0}", tr("imagery fade")),
                        JOptionPane.OK_CANCEL_OPTION,
                        JOptionPane.PLAIN_MESSAGE);
                if (answer == JOptionPane.OK_OPTION) {
                    Color colFadeColor = chooser.getColor();
                    btnFadeColor.setBackground(colFadeColor);
                    btnFadeColor.setText(ColorHelper.color2html(colFadeColor));
                }
            }
        });
View Full Code Here

TOP

Related Classes of javax.swing.JColorChooser$AccessibleJColorChooser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.