Skip to content

Commit

Permalink
Fix hint focus issues and also add more themes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Nov 23, 2023
1 parent 5654041 commit bc73df9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/main/java/net/pistonmaster/serverwrecker/gui/GUIFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ public void initComponents(Injector injector) {
public void open(Injector injector) {
setVisible(true);

// User says they are a first time user that wants hints
if (GUIClientProps.getBoolean("firstTimeUser", false)) {
SwingUtilities.invokeLater(() -> showHints(injector));
return;
}

// Ask whether the user wants hints
if (GUIClientProps.getBoolean("firstRun", true)) {
var result = JOptionPane.showConfirmDialog(
this,
Expand All @@ -78,15 +80,17 @@ public void open(Injector injector) {
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE
);

if (result == JOptionPane.YES_OPTION) {
GUIClientProps.setBoolean("firstTimeUser", true);
GUIClientProps.setBoolean("firstRun", false);

// Give the window a bit of time to close
TimeUtil.waitTime(50, TimeUnit.MILLISECONDS);
requestFocusInWindow();
SwingUtilities.invokeLater(() -> showHints(injector));
} else if (result == JOptionPane.NO_OPTION || result == JOptionPane.CLOSED_OPTION) {
GUIClientProps.setBoolean("firstTimeUser", false);
GUIClientProps.setBoolean("firstRun", false);
}

GUIClientProps.setBoolean("firstRun", false);
}
}

Expand Down
17 changes: 15 additions & 2 deletions src/main/java/net/pistonmaster/serverwrecker/gui/SWMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
package net.pistonmaster.serverwrecker.gui;

import com.formdev.flatlaf.FlatDarculaLaf;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatIntelliJLaf;
import com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme;
import com.formdev.flatlaf.FlatLightLaf;
import com.formdev.flatlaf.intellijthemes.*;
import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerIJTheme;
import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicIJTheme;
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
import com.formdev.flatlaf.themes.FlatMacLightLaf;
import javafx.stage.FileChooser;
Expand All @@ -48,9 +52,18 @@ public class SWMenuBar extends JMenuBar {
var tempThemes = new ArrayList<>(List.of(
FlatDarculaLaf.class,
FlatIntelliJLaf.class,
FlatDarkLaf.class,
FlatLightLaf.class,
FlatMacDarkLaf.class,
FlatMacLightLaf.class,
FlatOneDarkIJTheme.class
FlatOneDarkIJTheme.class,
FlatArcOrangeIJTheme.class,
FlatArcDarkOrangeIJTheme.class,
FlatCyanLightIJTheme.class,
FlatDarkPurpleIJTheme.class,
FlatMaterialDarkerIJTheme.class,
FlatMaterialOceanicIJTheme.class,
FlatCarbonIJTheme.class
));
THEMES = List.copyOf(tempThemes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ private void updateBalloonBorder() {

void showHint() {
var rootPane = SwingUtilities.getRootPane(hint.owner);
if (rootPane == null)
if (rootPane == null) {
return;
}

var layeredPane = rootPane.getLayeredPane();

Expand Down

0 comments on commit bc73df9

Please sign in to comment.