Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
Add more icon images
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo40Git committed Dec 30, 2017
1 parent f374be5 commit 7f0f3e7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin"/>
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/leo/oobfg/LoadFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JLabel;
Expand Down Expand Up @@ -34,7 +33,7 @@ public LoadFrame() {
add(loadLabel);
pack();
setLocationRelativeTo(null);
setIconImage(Toolkit.getDefaultToolkit().getImage(OOBFlagGen.class.getResource("/com/leo/oobfg/icon.png")));
setIconImages(OOBFlagGen.icons);
setVisible(true);
requestFocus();
}
Expand Down
40 changes: 34 additions & 6 deletions src/main/java/com/leo/oobfg/OOBFlagGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
Expand All @@ -22,6 +23,8 @@
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.text.ParseException;
import java.util.LinkedList;
import java.util.List;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
Expand All @@ -39,10 +42,21 @@
import javax.swing.text.MaskFormatter;

public class OOBFlagGen implements ActionListener {


public static List<Image> icons;

public static void initAppIcons() throws IOException {
icons = new LinkedList<>();
final String[] sizes = new String[] { "16", "32", "64" };
for (String size : sizes)
icons.add(Toolkit.getDefaultToolkit()
.getImage(OOBFlagGen.class.getResource("/com/leo/oobfg/icon" + size + ".png")));
}

public static final Version VERSION = new Version("1.0");
public static final String UPDATE_CHECK_SITE = "https://raw.githubusercontent.com/Leo40Git/OOBFlagGen/master/.version";
public static final String DOWNLOAD_SITE = "https://github.com/Leo40Git/OOBFlagGen/releases/";
public static final String ISSUES_SITE = "https://github.com/Leo40Git/OOBFlagGen/issues";

public static final String A_GENERATE = "generate";
public static final String A_COPY = "copy";
Expand All @@ -64,6 +78,15 @@ public class OOBFlagGen implements ActionListener {
private JRadioButton rdbtnDword;
private JButton btnUpdate;

public static void resourceError(Throwable e) {
System.err.println("Error while loading resources!");
e.printStackTrace();
JOptionPane.showMessageDialog(null,
"Could not load resources:" + e + "\nPlease report this error here:\n" + ISSUES_SITE,
"Could not load resources!", JOptionPane.ERROR_MESSAGE);
System.exit(1);
}

/**
* Launch the application.
*/
Expand Down Expand Up @@ -94,6 +117,11 @@ public static void main(String[] args) {
Config.setBoolean(Config.KEY_SKIP_UPDATE_CHECK, false);
skipucF = skipucR;
}
try {
initAppIcons();
} catch (IOException e1) {
resourceError(e1);
}
LoadFrame loadFrame;
if (skipucF) {
System.out.println("Update check: skip file detected, skipping");
Expand Down Expand Up @@ -130,7 +158,7 @@ public OOBFlagGen() {
*/
private void initialize() {
frame = new JFrame();
frame.setIconImage(Toolkit.getDefaultToolkit().getImage(OOBFlagGen.class.getResource("/com/leo/oobfg/icon.png")));
frame.setIconImages(icons);
frame.setResizable(false);
frame.setTitle("OOB Flag Generator v" + VERSION);
frame.setBounds(100, 100, 353, 334);
Expand Down Expand Up @@ -206,14 +234,14 @@ private void initialize() {
rdbtnWord.addActionListener(this);
rdbtnWord.setBounds(241, 35, 83, 23);
frame.getContentPane().add(rdbtnWord);

rdbtnDword = new JRadioButton("DWORD");
btnGSize.add(rdbtnDword);
rdbtnDword.setActionCommand(A_SIZE_DWORD);
rdbtnDword.addActionListener(this);
rdbtnDword.setBounds(241, 61, 109, 23);
frame.getContentPane().add(rdbtnDword);

btnUpdate = new JButton("Check for Updates");
btnUpdate.setActionCommand(A_UPDATE);
btnUpdate.addActionListener(this);
Expand Down Expand Up @@ -333,7 +361,7 @@ else if (btnGSize.isSelected(rdbtnDword.getModel()))
break;
}
}

public static void downloadFile(String url, File dest) throws IOException {
URL site = new URL(url);
try (InputStream siteIn = site.openStream();
Expand All @@ -342,7 +370,7 @@ public static void downloadFile(String url, File dest) throws IOException {
out.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
}
}

public static boolean browseTo(String url) throws URISyntaxException, IOException {
URI dlSite = new URI(url);
if (Desktop.isDesktopSupported())
Expand Down
Binary file added src/main/resources/com/leo/oobfg/icon32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/com/leo/oobfg/icon64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7f0f3e7

Please sign in to comment.