Fixed #450
This commit is contained in:
@@ -55,6 +55,7 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.util.Lang.thread;
|
||||||
import static org.jackhuang.hmcl.util.Lang.tryCast;
|
import static org.jackhuang.hmcl.util.Lang.tryCast;
|
||||||
|
|
||||||
public final class FXUtils {
|
public final class FXUtils {
|
||||||
@@ -249,12 +250,16 @@ public final class FXUtils {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
thread(() -> {
|
||||||
|
if (java.awt.Desktop.isDesktopSupported()) {
|
||||||
try {
|
try {
|
||||||
java.awt.Desktop.getDesktop().open(file);
|
java.awt.Desktop.getDesktop().open(file);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Logging.LOG.log(Level.SEVERE, "Unable to open " + path + " by java.awt.Desktop.getDesktop()::open", e);
|
Logging.LOG.log(Level.SEVERE, "Unable to open " + path + " by java.awt.Desktop.getDesktop()::open", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -265,6 +270,8 @@ public final class FXUtils {
|
|||||||
public static void openLink(String link) {
|
public static void openLink(String link) {
|
||||||
if (link == null)
|
if (link == null)
|
||||||
return;
|
return;
|
||||||
|
thread(() -> {
|
||||||
|
if (java.awt.Desktop.isDesktopSupported()) {
|
||||||
try {
|
try {
|
||||||
java.awt.Desktop.getDesktop().browse(new URI(link));
|
java.awt.Desktop.getDesktop().browse(new URI(link));
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@@ -277,6 +284,8 @@ public final class FXUtils {
|
|||||||
Logging.LOG.log(Level.WARNING, "Failed to open link: " + link, e);
|
Logging.LOG.log(Level.WARNING, "Failed to open link: " + link, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static void bindInt(JFXTextField textField, Property<Number> property) {
|
public static void bindInt(JFXTextField textField, Property<Number> property) {
|
||||||
textField.textProperty().bindBidirectional(property, SafeIntStringConverter.INSTANCE);
|
textField.textProperty().bindBidirectional(property, SafeIntStringConverter.INSTANCE);
|
||||||
|
|||||||
Reference in New Issue
Block a user