Refactor LaF methods

This commit is contained in:
Reinhard Pointner 2016-10-17 03:11:49 +08:00
parent 42305c0df6
commit c4c08d98b6
2 changed files with 21 additions and 5 deletions

View File

@ -35,7 +35,6 @@ import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.kohsuke.args4j.CmdLineException;
import org.w3c.dom.Document;
@ -186,10 +185,10 @@ public class Main {
private static void startUserInterface(ArgumentBean args) {
// use native LaF an all platforms (use platform-independent laf for standalone jar deployment)
try {
UIManager.setLookAndFeel(isExecutableJar() ? "javax.swing.plaf.nimbus.NimbusLookAndFeel" : UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
debug.log(Level.SEVERE, e.getMessage(), e);
if (isExecutableJar()) {
setNimbusLookAndFeel();
} else {
setSystemLookAndFeel();
}
// default frame

View File

@ -45,6 +45,7 @@ import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.Timer;
import javax.swing.UIManager;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.basic.BasicTableUI;
import javax.swing.text.JTextComponent;
@ -56,6 +57,22 @@ import net.filebot.Settings;
public final class SwingUI {
public static void setNimbusLookAndFeel() {
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
debug.log(Level.SEVERE, "Failed to set Nimbus LaF", e);
}
}
public static void setSystemLookAndFeel() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
debug.log(Level.SEVERE, "Failed to set System LaF", e);
}
}
public static void openURI(String uri) {
try {
Desktop.getDesktop().browse(URI.create(uri));