diff --git a/core/src/cn/harryh/arkpets/tray/HostTray.java b/core/src/cn/harryh/arkpets/tray/HostTray.java index 4c342c3b..7503b512 100644 --- a/core/src/cn/harryh/arkpets/tray/HostTray.java +++ b/core/src/cn/harryh/arkpets/tray/HostTray.java @@ -32,6 +32,17 @@ public class HostTray { private static HostTray instance; static { + // Avoid AWT Thread problem. + SwingUtilities.invokeLater(() -> { + try { + String laf = UIManager.getSystemLookAndFeelClassName(); + if (laf.contains("WindowsLookAndFeel")) { + UIManager.put("MenuItem.margin",new Insets(2,-15,2,2)); + UIManager.put("Menu.margin",new Insets(2,-15,2,2)); + } + UIManager.setLookAndFeel(laf); + } catch (Exception ignored) {} + }); Const.FontsConfig.loadFontsToSwing(); } @@ -87,6 +98,8 @@ public void mouseClicked(MouseEvent e) { showStage(); } }); + SwingUtilities.updateComponentTreeUI(popMenu); + popMenu.pack(); } else { Logger.error("HostTray", "Tray is not supported."); } diff --git a/core/src/cn/harryh/arkpets/tray/MemberTray.java b/core/src/cn/harryh/arkpets/tray/MemberTray.java index 1ebb6153..e3a9bcf4 100644 --- a/core/src/cn/harryh/arkpets/tray/MemberTray.java +++ b/core/src/cn/harryh/arkpets/tray/MemberTray.java @@ -7,6 +7,7 @@ import cn.harryh.arkpets.concurrent.SocketData; import javax.swing.*; +import java.awt.*; import java.util.UUID; @@ -21,6 +22,15 @@ public abstract class MemberTray { protected final String name; static { + // Avoid AWT Thread problem. + try { + String laf = UIManager.getSystemLookAndFeelClassName(); + if (laf.contains("WindowsLookAndFeel")) { + UIManager.put("MenuItem.margin", new Insets(2, -15, 2, 2)); + UIManager.put("Menu.margin", new Insets(2, -15, 2, 2)); + } + UIManager.setLookAndFeel(laf); + } catch (Exception ignored) {} Const.FontsConfig.loadFontsToSwing(); } @@ -44,6 +54,13 @@ public MemberTray(String name) { optTransparentDis .addActionListener(e -> sendOperation(SocketData.Operation.NO_TRANSPARENT_MODE)); optChangeStage .addActionListener(e -> sendOperation(SocketData.Operation.CHANGE_STAGE)); optExit .addActionListener(e -> sendOperation(SocketData.Operation.LOGOUT)); + + optKeepAnimEn .setIcon(null); + optKeepAnimDis .setIcon(null); + optTransparentEn .setIcon(null); + optTransparentDis .setIcon(null); + optChangeStage .setIcon(null); + optExit .setIcon(null); } abstract public void onExit();