Merge pull request #1856 from SiboVG/issue-1851

[#1851] Reset button foreground on focus loss
This commit is contained in:
Sibo Van Gool 2022-11-29 00:04:08 +01:00 committed by GitHub
commit 462e264697
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,8 @@ import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Graphics;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
public class SelectColorButton extends JButton {
public SelectColorButton() {
@ -53,5 +55,13 @@ public class SelectColorButton extends JButton {
}
}
});
// Need to add this, otherwise the foreground can remain in the selectForeground state when the button is clicked
addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
setForeground(UIManager.getColor("Button.foreground"));
}
});
}
}