修改颜色选择器面板 [英] Modifying a color chooser panel

查看:116
本文介绍了修改颜色选择器面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建颜色选择器,需要修改颜色选择器面板之一.

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

我想要的是,我想通过RGB字段输入输入值以设置颜色,问题是RGB值似乎被禁用了,API内是否有一种方法可以打开RGB输入以获取值?

What I wanted was, I want to enter input values via the RGB fields to set the colour,The problem is the RGB values seem to be disabled is there a method within the api to turn on the RGB inputs to take a value?

推荐答案

在这里看起来不错.

import javax.swing.*;

class ColorChooserTest {

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


反正您可以将RGB滑块面板和HSB面板组合在一起吗?

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.

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);
            }
        });
    }
}

这篇关于修改颜色选择器面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆