made window look native and added icon

This commit is contained in:
2025-06-22 18:47:51 +02:00
parent 9de6cd63d1
commit d6e0ebc196
4 changed files with 10 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ import com.vaporvee.loadsupport.platform.Services;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.net.URI; import java.net.URI;
import java.util.Objects;
public class Allocated { public class Allocated {
public static float memoryInGB; public static float memoryInGB;
@@ -48,15 +49,18 @@ public class Allocated {
try { try {
if (enoughMemory) { if (enoughMemory) {
enoughMemory = false; enoughMemory = false;
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
String[] warning = getWarningMessage(); String[] warning = getWarningMessage();
errorWindow = new JFrame(warning[0]); errorWindow = new JFrame(warning[0]);
Image icon = new ImageIcon(Objects.requireNonNull(Allocated.class.getResource("/assets/" + Constants.MOD_ID + "/icon.png"))).getImage();
errorWindow.setIconImage(icon);
errorWindow.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); errorWindow.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
errorWindow.setSize(500, 350); errorWindow.setSize(500, 350);
errorWindow.setLocationRelativeTo(null); errorWindow.setLocationRelativeTo(null);
JLabel message = new JLabel( JLabel message = new JLabel(
"<html><p style=\"width:290px; font-size:16px;\">" + warning[1] + "</p></html>", "<html><p style=\"width:350px; font-size:20px;\">" + warning[1] + "</p></html>",
JLabel.CENTER JLabel.CENTER
); );
@@ -88,8 +92,10 @@ public class Allocated {
errorWindow.setVisible(true); errorWindow.setVisible(true);
}); });
} }
} catch (RuntimeException e) { } catch (RuntimeException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
Constants.LOG.error(String.valueOf(e)); Constants.LOG.error(String.valueOf(e));
} catch (UnsupportedLookAndFeelException e) {
throw new RuntimeException(e);
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -12,7 +12,7 @@
"sources": "https://github.com/FabricMC/fabric-example-mod" "sources": "https://github.com/FabricMC/fabric-example-mod"
}, },
"license": "${license}", "license": "${license}",
"icon": "${mod_id}.png", "icon": "assets/${mod_id}/icon.png",
"environment": "*", "environment": "*",
"entrypoints": { "entrypoints": {
"main": [ "main": [

View File

@@ -8,7 +8,7 @@ version = "${version}" #mandatory
displayName = "${mod_name}" #mandatory displayName = "${mod_name}" #mandatory
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://docs.neoforged.net/docs/misc/updatechecker/) #updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://docs.neoforged.net/docs/misc/updatechecker/)
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI) #displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI)
logoFile="${mod_id}.png" #optional logoFile="assets/${mod_id}/icon.png" #optional
credits="${credits}" #optional credits="${credits}" #optional
authors = "${mod_author}" #optional authors = "${mod_author}" #optional
description = '''${description}''' #mandatory (Supports multiline text) description = '''${description}''' #mandatory (Supports multiline text)