Change color picker

I am creating a color picker and have to change one of the color picker panels.

Color chooser

What I wanted, I would like to enter the input values ​​through the RGB fields to set the color. The problem is that the RGB values ​​seem to be disabled, there is a method inside the api to enable the RGB inputs to accept the value

+3
source share
1 answer

It seems good here.

Color chooser test

import javax.swing.*; class ColorChooserTest { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, new JColorChooser()); } }); } } 

Anyway, can you combine the RGB slider and the HSB?

Yes, apparently, it is possible. Check out this (very fragile, poorly laid out) example.

Color Chooser Test 2

 import java.awt.*; import javax.swing.*; import javax.swing.colorchooser.*; import javax.swing.border.*; class ColorChooserTest2 { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JColorChooser cc = new JColorChooser(); AbstractColorChooserPanel[] panels = cc.getChooserPanels(); JPanel p = new JPanel(); panels[1].setBorder( new TitledBorder(panels[1].getDisplayName())); p.add(panels[1]); panels[2].setBorder( new TitledBorder(panels[2].getDisplayName())); p.add(panels[2]); JPanel gui = new JPanel(new BorderLayout(2,2)); gui.add(p, BorderLayout.CENTER); gui.add(cc.getPreviewPanel(), BorderLayout.SOUTH); JOptionPane.showMessageDialog(null, gui); } }); } } 
+7
source

Source: https://habr.com/ru/post/1393971/


All Articles