Browse Source

Only add listeners if title is drawn in swing.

pull/75/head
weisj 5 years ago
parent
commit
ffe188ad89
  1. 12
      macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java

12
macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java

@ -158,7 +158,7 @@ public class MacOSTitlePane extends CustomTitlePane {
}
private void installListeners() {
if (window != null) {
if (window != null && useCustomTitle()) {
windowListener = new WindowHandler();
window.addWindowListener(windowListener);
propertyChangeListener = new PropertyChangeHandler();
@ -226,22 +226,18 @@ public class MacOSTitlePane extends CustomTitlePane {
protected class WindowHandler extends WindowAdapter {
public void windowActivated(final WindowEvent ev) {
if (useCustomTitle()) {
titleLabel.setForeground(activeForeground);
}
titleLabel.setForeground(activeForeground);
}
public void windowDeactivated(final WindowEvent ev) {
if (useCustomTitle()) {
titleLabel.setForeground(inactiveForeground);
}
titleLabel.setForeground(inactiveForeground);
}
}
protected class PropertyChangeHandler implements PropertyChangeListener {
public void propertyChange(final PropertyChangeEvent pce) {
String name = pce.getPropertyName();
if (useCustomTitle() && "title".equals(name)) {
if ("title".equals(name)) {
titleLabel.setText(pce.getNewValue() == null ? "" : pce.getNewValue().toString());
repaint();
}

Loading…
Cancel
Save