add icon, fix icon positioning
This commit is contained in:
parent
a3960b933f
commit
b6d904595a
|
@ -1,9 +1,11 @@
|
||||||
package dev.frogmc.frogloader.impl.gui.component;
|
package dev.frogmc.frogloader.impl.gui.component;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.plaf.basic.BasicBorders;
|
import javax.swing.plaf.basic.BasicBorders;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.impl.mod.ModDependencyResolver;
|
import dev.frogmc.frogloader.impl.mod.ModDependencyResolver;
|
||||||
|
@ -28,17 +30,29 @@ public class DependencyErrorEntry extends JPanel {
|
||||||
desc.setText("<html>" + description.replace("<", "<").replace("\n", "<br>") + "</html>");
|
desc.setText("<html>" + description.replace("<", "<").replace("\n", "<br>") + "</html>");
|
||||||
text.add(desc);
|
text.add(desc);
|
||||||
|
|
||||||
add(text, BorderLayout.NORTH);
|
Box top = Box.createHorizontalBox();
|
||||||
|
add(top, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
if (icon != null) {
|
||||||
|
URL location = getClass().getResource("/"+icon);
|
||||||
|
|
||||||
|
if (location != null) {
|
||||||
|
try {
|
||||||
|
int size = 100;
|
||||||
|
Image image = ImageIO.read(location).getScaledInstance(size, size, Image.SCALE_SMOOTH);
|
||||||
|
Box container = Box.createVerticalBox();
|
||||||
|
container.add(new JLabel(new ImageIcon(image)));
|
||||||
|
container.add(Box.createVerticalGlue());
|
||||||
|
top.add(container);
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
top.add(text);
|
||||||
|
|
||||||
this.actions = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
this.actions = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
add(this.actions, BorderLayout.SOUTH);
|
add(this.actions, BorderLayout.SOUTH);
|
||||||
|
|
||||||
if (icon != null) {
|
|
||||||
URL location = getClass().getResource(icon);
|
|
||||||
|
|
||||||
if (location != null)
|
|
||||||
add(new JLabel(new ImageIcon(location)), BorderLayout.WEST);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAction(String label, ActionListener listener) {
|
public void addAction(String label, ActionListener listener) {
|
||||||
|
|
|
@ -87,6 +87,7 @@ public class FrogModProvider implements ModProvider {
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
if (Files.exists(dir)) {
|
||||||
Files.walkFileTree(dir, new SimpleFileVisitor<>() {
|
Files.walkFileTree(dir, new SimpleFileVisitor<>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||||
|
@ -100,6 +101,7 @@ public class FrogModProvider implements ModProvider {
|
||||||
return super.postVisitDirectory(dir, exc);
|
return super.postVisitDirectory(dir, exc);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Failed to clear extracted jij mods!", e);
|
LOGGER.error("Failed to clear extracted jij mods!", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,4 +9,5 @@ license = "Apache-2.0"
|
||||||
credits = [
|
credits = [
|
||||||
{ name = "FrogMC Team", roles = ["author"] }
|
{ name = "FrogMC Team", roles = ["author"] }
|
||||||
]
|
]
|
||||||
|
icon = "icon.png"
|
||||||
|
|
||||||
|
|
BIN
src/main/resources/icon.png
Normal file
BIN
src/main/resources/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
Loading…
Reference in a new issue