List of usage examples for javax.swing JColorChooser JColorChooser
public JColorChooser()
From source file:Main.java
public static void main(String[] argv) { JColorChooser chooser = new JColorChooser(); chooser.addChooserPanel(new MyChooserPanel()); }
From source file:JColorChooserWithCustomPreviewPanel.java
public static void main(String[] a) { final JLabel previewLabel = new JLabel("I Love Swing", JLabel.CENTER); previewLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48)); previewLabel.setSize(previewLabel.getPreferredSize()); previewLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); JColorChooser colorChooser = new JColorChooser(); colorChooser.setPreviewPanel(previewLabel); JDialog d = colorChooser.createDialog(null, "", true, colorChooser, null, null); d.setVisible(true);/*from w w w .j a v a 2 s . co m*/ }
From source file:MainClass.java
public static void main(String[] a) { final JColorChooser colorChooser = new JColorChooser(); SystemColorChooserPanel newChooser = new SystemColorChooserPanel(); colorChooser.addChooserPanel(newChooser); ActionListener okActionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println(colorChooser.getColor()); }//from w w w .ja v a 2 s.c o m }; ActionListener cancelActionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Cancel"); } }; final JDialog dialog = JColorChooser.createDialog(null, "Change Button Background", true, colorChooser, okActionListener, cancelActionListener); dialog.setVisible(true); }
From source file:SystemColorChooserPanel.java
public static void main(String[] a) { JColorChooser colorChooser = new JColorChooser(); colorChooser.addChooserPanel(new SystemColorChooserPanel()); JDialog d = colorChooser.createDialog(null, "", true, colorChooser, null, null); d.setVisible(true);// w ww. jav a 2 s .co m }
From source file:ColorPicker3.java
public ColorPicker3() { super("JColorChooser Test Frame"); setSize(200, 100);//from w w w . j a v a 2 s . co m final JButton go = new JButton("Show JColorChoser"); final Container contentPane = getContentPane(); go.addActionListener(new ActionListener() { final JColorChooser chooser = new JColorChooser(); boolean first = true; public void actionPerformed(ActionEvent e) { if (first) { first = false; GrayScalePanel gsp = new GrayScalePanel(); chooser.addChooserPanel(gsp); chooser.setPreviewPanel(new CustomPane()); } JDialog dialog = JColorChooser.createDialog(ColorPicker3.this, "Demo 3", true, chooser, new ActionListener() { public void actionPerformed(ActionEvent e) { c = chooser.getColor(); } }, null); dialog.setVisible(true); contentPane.setBackground(c); } }); contentPane.add(go, BorderLayout.SOUTH); // addWindowListener(new BasicWindowMonitor()); // 1.1 & 1.2 setDefaultCloseOperation(EXIT_ON_CLOSE); }
From source file:fxts.stations.ui.UIFrontEnd.java
/** * Creating wrapper around com.fxcm.ui.colochooser.ColorChooser object or * wrapper around javax.swing.JColorChooser object * * @return ColorChooserWrapper//from w w w . j a v a 2 s .com */ public ColorChooserWrapper getColorChooser() { try { return new ColorChooserWrapper(new ColorChooser()); } catch (Exception e) { e.printStackTrace(); } try { return new ColorChooserWrapper(new JColorChooser()); } catch (Exception e) { mLogger.error("!!!! Standard class javax.swing.JColorChooser loading error"); e.printStackTrace(); return null; } }
From source file:SerialTransferTest.java
public SerialTransferFrame() { setTitle("SerialTransferTest"); chooser = new JColorChooser(); add(chooser, BorderLayout.CENTER); JPanel panel = new JPanel(); JButton copyButton = new JButton("Copy"); panel.add(copyButton);// www . j av a2 s. c o m copyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { copy(); } }); JButton pasteButton = new JButton("Paste"); panel.add(pasteButton); pasteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { paste(); } }); add(panel, BorderLayout.SOUTH); pack(); }
From source file:SwingDnDTest.java
public SwingDnDFrame() { setTitle("SwingDnDTest"); JTabbedPane tabbedPane = new JTabbedPane(); JList list = SampleComponents.list(); tabbedPane.addTab("List", list); JTable table = SampleComponents.table(); tabbedPane.addTab("Table", table); JTree tree = SampleComponents.tree(); tabbedPane.addTab("Tree", tree); JFileChooser fileChooser = new JFileChooser(); tabbedPane.addTab("File Chooser", fileChooser); JColorChooser colorChooser = new JColorChooser(); tabbedPane.addTab("Color Chooser", colorChooser); final JTextArea textArea = new JTextArea(4, 40); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setBorder(new TitledBorder(new EtchedBorder(), "Drag text here")); JTextField textField = new JTextField("Drag color here"); textField.setTransferHandler(new TransferHandler("background")); tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { textArea.setText(""); }/*from www . j ava 2s . c o m*/ }); tree.setDragEnabled(true); table.setDragEnabled(true); list.setDragEnabled(true); fileChooser.setDragEnabled(true); colorChooser.setDragEnabled(true); textField.setDragEnabled(true); add(tabbedPane, BorderLayout.NORTH); add(scrollPane, BorderLayout.CENTER); add(textField, BorderLayout.SOUTH); pack(); }
From source file:LabelDnD2.java
public LabelDnD2() { super(new BorderLayout()); JColorChooser chooser = new JColorChooser(); chooser.setDragEnabled(true);//from ww w . ja v a 2 s . c o m label = new JLabel("I'm a Label and I accept color!", SwingConstants.LEADING); label.setTransferHandler(new TransferHandler("foreground")); MouseListener listener = new DragMouseAdapter(); label.addMouseListener(listener); JPanel lpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t2 = BorderFactory.createTitledBorder("JLabel: drop color onto the label"); lpanel.add(label); lpanel.setBorder(t2); add(chooser, BorderLayout.CENTER); add(lpanel, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:cz.lidinsky.editor.TableCellEditor.java
/** * Initialize all of the components/* w w w . j a v a2s . co m*/ */ public TableCellEditor() { // color chooser button = new JButton(); button.setActionCommand("edit"); button.addActionListener(this); button.setBorderPainted(false); button.addFocusListener(this); colorChooser = new JColorChooser(); colorChooser.addChooserPanel(new AliasChooser()); colorChooser.addFocusListener(this); dialog = JColorChooser.createDialog(button, "Pick a Color", true, colorChooser, this, null); // text editor textField = new JTextField(); textField.addFocusListener(this); // combo chooser comboBox = new JComboBox(); comboBox.addFocusListener(this); // check box checkBox = new JCheckBox(); checkBox.addFocusListener(this); }