我试图制作一个涉及JColorChooser Swatches Component的绘图应用程序,并且我试图让我的UI成为某种颜色。我能够通过设置背景几乎改变颜色,除了"最近"周围的一个小区域。框。 Screenshot
任何帮助都将不胜感激,我将下面的部分代码粘贴到上下文中:
//Sets up color chooser
chooser = new JColorChooser(Color.BLACK);
AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
for (int i = 0; i < panels.length; i++) {
if (!panels[i].getDisplayName().equalsIgnoreCase("Swatches"))
chooser.removeChooserPanel(panels[i]);
else {
panels[i].setBackground(new Color(0, 155, 228));
}
}
chooser.setPreviewPanel(new JPanel());
//Sets up size slider
sizeSlide = new JSlider(1, 45);
//Adds Color/Size to one control panel, adds new panel to bottom of
//main
optionP = new JPanel();
optionP.setBackground(new Color(0, 155, 228));
optionP.setLayout(new BorderLayout());
optionP.add(sizeSlide, BorderLayout.EAST);
optionP.add(chooser, BorderLayout.WEST);
this.add(optionP, BorderLayout.SOUTH);