Modifying a color chooser panel

后端 未结 1 1840
北荒
北荒 2021-01-21 10:19

I am creating a colour chooser and need to modify one of the colour chooser panels.

\"Color

What

相关标签:
1条回答
  • 2021-01-21 10:39

    Seems fine 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());
                }
            });
        }
    }
    

    Is there anyway you can combine the RGB slider panel and the HSB panel?

    Yes, apparently it is possible. Check 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);
                }
            });
        }
    }
    
    0 讨论(0)
提交回复
热议问题