colorButton = (new JButton() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(this.getForeground());
g.fillRoundRect((this.getWidth()-30)/2, (this.getHeight()-15)/2, 30, 15,5,5);
}
});
colorButton.setPreferredSize(new Dimension(50,25));
colorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//ermitteln der aktuellen Farbe damit die im Dialog ausgewählt ist, wo die herkommt musst
//du wissen :D meine kommt hier grad aus nem Hashtable
Color actualColor = (Color) styleTable.get(selectedStyle).getAttributes().get(TextAttribute.FOREGROUND);
Color newColor = JColorChooser.showDialog(fontStylePanel, "neue Schriftfarbe", actualColor);
if (newColor != null) {
((JButton) e.getSource()).setForeground(newColor);
//sonstiger spezifischer kram
}//if
}//actionPerformed
});