我想将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));
}
});
感谢您的反馈