Java – modify color selector panel
                                        
                    •
                    Java                                    
                I am creating a color selector and need to modify one of the color selector panels
What I want is that I want to input the input value through the RGB field to set the color. The problem is that the RGB value seems to be disabled. Is there a way to turn on the RGB input in the API to obtain the value?
Solution
It's looks good.
import javax.swing.*;
class ColorChooserTest {
    public static void main(String[] args) {
        SwingUtilities.invokelater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(null,new JColorChooser());
            }
        });
    }
}
Yes, obviously it is possible Check this (very fragile, poorly laid out) example
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);
            }
        });
    }
}
                
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        