-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Open Log" Button to when an error popup occurs (#75)
- Loading branch information
1 parent
3edfaec
commit d260e1c
Showing
5 changed files
with
34 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package net.minecraftforge.installer; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class SwingUtil { | ||
public static JButton createLogButton() { | ||
JButton button = new JButton("Open log"); | ||
button.addActionListener(ev -> { | ||
File file = new File("installer.log"); | ||
try { | ||
if (file.exists()) | ||
Desktop.getDesktop().open(file); | ||
} catch (IOException e) { | ||
// Handle any errors that may occur during file opening | ||
e.printStackTrace(); | ||
|
||
// Show the error. Does not happen on headless. | ||
// Can only occur on NON-Headless, so its safe to just show the error | ||
JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); | ||
} | ||
}); | ||
return button; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,4 +143,5 @@ public static String replaceTokens(Map<String, ? extends Supplier<String>> token | |
|
||
return buf.toString(); | ||
} | ||
|
||
} |