Make Color config options show their colour instead of "Pick a color" (#3583)

- Make Color config options show their colour instead of "Pick a color"
- Made null Colors show "Pick a color"
This commit is contained in:
Hydrox6
2018-06-09 03:09:21 +01:00
committed by Tomas Slusny
parent c261e387ac
commit 9634eb8e06

View File

@@ -505,9 +505,21 @@ public class ConfigPanel extends PluginPanel
if (cid.getType() == Color.class)
{
String existing = configManager.getConfiguration(cd.getGroup().keyName(), cid.getItem().keyName());
Color existingColor = existing == null ? Color.BLACK : Color.decode(existing);
JButton colorPicker = new JButton("Pick a color");
Color existingColor;
JButton colorPicker;
if (existing == null)
{
existingColor = Color.BLACK;
colorPicker = new JButton("Pick a color");
}
else
{
existingColor = Color.decode(existing);
colorPicker = new JButton("#" + Integer.toHexString(existingColor.getRGB()).substring(2).toUpperCase());
}
colorPicker.setFocusable(false);
colorPicker.setBackground(existingColor);
colorPicker.addMouseListener(new MouseAdapter()