如何将menuItem的图标设置为当前的JColorChooser颜色?

时间:2016-02-18 07:32:26

标签: java eclipse user-interface jmenu jcolorchooser

我想将myColorItem菜单项设置为用户从JColorChooser中选择的颜色。我尝试了这个,但显然我不能将颜色投射到ImageIcon

myColorItem = new JMenuItem("Color...");

    myColorItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent theEvent) {
            Color color = JColorChooser.showDialog(null, "", myDefaultColor);


       // This is what is not working 
            myColorItem.setIcon(new ImageIcon(color));
        }
    });

感谢您的反馈

0 个答案:

没有答案