Skip to content

Commit

Permalink
Fix for visual bug with overlapping/unreadable text in color settings (
Browse files Browse the repository at this point in the history
  • Loading branch information
WolframPfeifer authored Sep 2, 2024
2 parents f349711 + c3edffa commit 0fda856
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ public Component getTableCellRendererComponent(JTable table, Object value,
}

private Icon drawRect(Color c, int size) {
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
/*
* Not sure if the alpha channel is used. Highlights seem to be blended correctly
* even if the color is not transparent at all. However, make sure to use ARGB to
* avoid black icons here ...
*/
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.getGraphics();
g.setColor(c);
g.fillRect(0, 0, size, size);
Expand Down Expand Up @@ -167,6 +172,10 @@ class HexColorCellEditor extends DefaultCellEditor {

HexColorCellEditor(JTextField textField) {
super(textField);

// this is somehow important to avoid visual artifacts such as overlapping text:
textField.setOpaque(false);

textField.addActionListener(e -> stopCellEditing());
textField.getDocument().addDocumentListener(new DocumentListener() {
@Override
Expand Down

0 comments on commit 0fda856

Please sign in to comment.