Browse Source

Windows: Fix errorprone warnings

pull/270/head
weisj 3 years ago
parent
commit
81fc63ff10
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 6
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java
  2. 22
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

6
windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java

@ -23,7 +23,11 @@ package com.github.weisj.darklaf.platform.windows;
import java.awt.Window; import java.awt.Window;
/** @author Jannis Weis */ /**
* Boundary to the native window decorations implementation.
*
* @author Jannis Weis
*/
public final class JNIDecorationsWindows { public final class JNIDecorationsWindows {
public static native long getWindowHWND(final Window window, final String javaLibPath); public static native long getWindowHWND(final Window window, final String javaLibPath);

22
windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

@ -45,7 +45,11 @@ import com.github.weisj.darklaf.util.PropertyUtil;
import com.github.weisj.darklaf.util.Scale; import com.github.weisj.darklaf.util.Scale;
import com.github.weisj.darklaf.util.StringUtil; import com.github.weisj.darklaf.util.StringUtil;
/** @author Jannis Weis */ /**
* Swing implementation of the native windows titlebar.
*
* @author Jannis Weis
*/
public class WindowsTitlePane extends CustomTitlePane { public class WindowsTitlePane extends CustomTitlePane {
public static final String KEY_RESIZABLE = "resizable"; public static final String KEY_RESIZABLE = "resizable";
public static final String KEY_STATE = "state"; public static final String KEY_STATE = "state";
@ -173,6 +177,7 @@ public class WindowsTitlePane extends CustomTitlePane {
} }
} }
@Override
public void install() { public void install() {
if (window != null) { if (window != null) {
if (!installDecorations()) return; if (!installDecorations()) return;
@ -422,6 +427,7 @@ public class WindowsTitlePane extends CustomTitlePane {
} }
} }
@Override
public void paintComponent(final Graphics g) { public void paintComponent(final Graphics g) {
if (getFrame() != null) { if (getFrame() != null) {
setState(getFrame().getExtendedState()); setState(getFrame().getExtendedState());
@ -454,6 +460,7 @@ public class WindowsTitlePane extends CustomTitlePane {
return getDecorationStyle() != JRootPane.NONE && menuBarStealer.hasMenuBar(); return getDecorationStyle() != JRootPane.NONE && menuBarStealer.hasMenuBar();
} }
@Override
public JRootPane getRootPane() { public JRootPane getRootPane() {
return rootPane; return rootPane;
} }
@ -493,7 +500,7 @@ public class WindowsTitlePane extends CustomTitlePane {
LookAndFeel.uninstallBorder(rootPane); LookAndFeel.uninstallBorder(rootPane);
} else { } else {
Border border = rootPane.getBorder(); Border border = rootPane.getBorder();
if (oldBorder != null && border == null || border instanceof UIResource) { if (oldBorder != null && (border == null || border instanceof UIResource)) {
rootPane.setBorder(oldBorder); rootPane.setBorder(oldBorder);
} }
} }
@ -620,6 +627,7 @@ public class WindowsTitlePane extends CustomTitlePane {
return bimage; return bimage;
} }
@SuppressWarnings("EmptyCatch")
private void ensureImageLoaded(final Component c, final Image img) { private void ensureImageLoaded(final Component c, final Image img) {
MediaTracker tracker = new MediaTracker(c); MediaTracker tracker = new MediaTracker(c);
tracker.addImage(img, 0); tracker.addImage(img, 0);
@ -634,6 +642,7 @@ public class WindowsTitlePane extends CustomTitlePane {
super(UIManager.getString("Actions.close", getLocale()), closeIcon); super(UIManager.getString("Actions.close", getLocale()), closeIcon);
} }
@Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
close(); close();
} }
@ -644,6 +653,7 @@ public class WindowsTitlePane extends CustomTitlePane {
super(UIManager.getString("Actions.minimize", getLocale()), minimizeIcon); super(UIManager.getString("Actions.minimize", getLocale()), minimizeIcon);
} }
@Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
minimize(); minimize();
} }
@ -654,6 +664,7 @@ public class WindowsTitlePane extends CustomTitlePane {
super(UIManager.getString("Actions.maximize", getLocale()), maximizeIcon); super(UIManager.getString("Actions.maximize", getLocale()), maximizeIcon);
} }
@Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
maximize(); maximize();
} }
@ -664,6 +675,7 @@ public class WindowsTitlePane extends CustomTitlePane {
super(UIManager.getString("Actions.restore", getLocale()), restoreIcon); super(UIManager.getString("Actions.restore", getLocale()), restoreIcon);
} }
@Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
restore(); restore();
} }
@ -740,8 +752,10 @@ public class WindowsTitlePane extends CustomTitlePane {
} }
private class TitlePaneLayout implements LayoutManager { private class TitlePaneLayout implements LayoutManager {
@Override
public void addLayoutComponent(final String name, final Component c) {} public void addLayoutComponent(final String name, final Component c) {}
@Override
public void removeLayoutComponent(final Component c) {} public void removeLayoutComponent(final Component c) {}
@Override @Override
@ -749,10 +763,12 @@ public class WindowsTitlePane extends CustomTitlePane {
return getPreferredSize(); return getPreferredSize();
} }
@Override
public Dimension minimumLayoutSize(final Container c) { public Dimension minimumLayoutSize(final Container c) {
return preferredLayoutSize(c); return preferredLayoutSize(c);
} }
@Override
public void layoutContainer(final Container c) { public void layoutContainer(final Container c) {
if (hideTitleBar()) return; if (hideTitleBar()) return;
boolean leftToRight = isLeftToRight(window); boolean leftToRight = isLeftToRight(window);
@ -884,10 +900,12 @@ public class WindowsTitlePane extends CustomTitlePane {
protected class WindowHandler extends WindowAdapter { protected class WindowHandler extends WindowAdapter {
@Override
public void windowActivated(final WindowEvent ev) { public void windowActivated(final WindowEvent ev) {
setActive(true); setActive(true);
} }
@Override
public void windowDeactivated(final WindowEvent ev) { public void windowDeactivated(final WindowEvent ev) {
setActive(false); setActive(false);
} }

Loading…
Cancel
Save