Merges 'n stuff'
This commit is contained in:
parent
b9678ba36d
commit
aba063fb49
@ -4,9 +4,15 @@ import javafx.application.Application;
|
|||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.web.WebEngine;
|
||||||
|
import javafx.scene.web.WebView;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.StageStyle;
|
import javafx.stage.StageStyle;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Main extends Application {
|
public class Main extends Application {
|
||||||
|
|
||||||
private double xOffset = 0;
|
private double xOffset = 0;
|
||||||
@ -17,16 +23,24 @@ public class Main extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception{
|
public void start(Stage primaryStage) throws Exception{
|
||||||
primaryStage.initStyle(StageStyle.UNDECORATED);
|
primaryStage.initStyle(StageStyle.UNDECORATED);
|
||||||
Parent root = FXMLLoader.load(getClass().getResource("Main_Launcher.fxml"));
|
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
|
||||||
primaryStage.setTitle("Team-Avion Launcher [WIP]");
|
primaryStage.setTitle("Team-Avion Launcher [WIP]");
|
||||||
primaryStage.setScene(new Scene(root, 900, 500));
|
primaryStage.setScene(new Scene(root, 900, 500));
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
|
||||||
primaryStage.maximizedProperty().addListener((observable, oldValue, newValue) -> {
|
System.out.println(getDefaultBrowser());
|
||||||
if (newValue) {
|
|
||||||
primaryStage.setMaximized(false);
|
final WebView browser = new WebView();
|
||||||
}
|
final WebEngine webEngine = browser.getEngine();
|
||||||
});
|
webEngine.setJavaScriptEnabled(true);
|
||||||
|
webEngine.load("google.com");
|
||||||
|
System.out.println(webEngine.getDocument());
|
||||||
|
|
||||||
|
Runtime.getRuntime().exec(getDefaultBrowser()+" youtube.com");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
root.lookup("#exit").setOnMouseClicked(event -> primaryStage.close());
|
root.lookup("#exit").setOnMouseClicked(event -> primaryStage.close());
|
||||||
|
|
||||||
// Drag
|
// Drag
|
||||||
@ -42,4 +56,40 @@ public class Main extends Application {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getDefaultBrowser()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Get registry where we find the default browser
|
||||||
|
Process process = Runtime.getRuntime().exec("REG QUERY HKEY_CLASSES_ROOT\\http\\shell\\open\\command");
|
||||||
|
Scanner kb = new Scanner(process.getInputStream());
|
||||||
|
while (kb.hasNextLine())
|
||||||
|
{
|
||||||
|
|
||||||
|
// Get output from the terminal, and replace all '\' with '/' (makes regex a bit more manageable)
|
||||||
|
String registry = (kb.nextLine()).replaceAll("\\\\", "/").trim();
|
||||||
|
|
||||||
|
// Extract the default browser
|
||||||
|
Matcher matcher = Pattern.compile("\"(.*)\"").matcher(registry);
|
||||||
|
if (matcher.find())
|
||||||
|
{
|
||||||
|
// Scanner is no longer needed if match is found, so close it
|
||||||
|
kb.close();
|
||||||
|
String defaultBrowser = matcher.group(1);
|
||||||
|
|
||||||
|
// Capitalize first letter and return String
|
||||||
|
defaultBrowser = defaultBrowser.substring(0, 1).toUpperCase() + defaultBrowser.substring(1, defaultBrowser.length());
|
||||||
|
return defaultBrowser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Match wasn't found, still need to close Scanner
|
||||||
|
kb.close();
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// Have to return something if everything fails
|
||||||
|
return "Error: Unable to get default browser";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
23
src/Launcher/sample.fxml
Normal file
23
src/Launcher/sample.fxml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Hyperlink?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
<?import javafx.scene.shape.Rectangle?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
|
<Pane id="pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500" prefWidth="900" style="-fx-background-color: rgb(42, 44, 58);" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<children>
|
||||||
|
<Rectangle id="rectangle" arcHeight="5.0" arcWidth="5.0" fill="white" height="50.0" strokeType="INSIDE" style="-fx-fill: rgb(29, 31, 48);" width="900.0" />
|
||||||
|
<Button id="exit" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="862.0" layoutY="13.0" mnemonicParsing="false" style="-fx-background-color: rgb(29, 31, 48);" stylesheets="@../assets/style/nav.css" text="X" textFill="WHITE" />
|
||||||
|
<Label layoutX="46.0" layoutY="11.0" text="Team Avion Launcher" textFill="WHITE">
|
||||||
|
<font>
|
||||||
|
<Font name="Centaur" size="24.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#e4e4e4" height="450.0" layoutX="-1.0" layoutY="50.0" strokeType="INSIDE" style="-fx-fill: rgb(29, 31, 48);" width="145.0" />
|
||||||
|
<Hyperlink id="hyperlink" layoutX="26.0" layoutY="66.0" text="Our Modpacks" />
|
||||||
|
<Hyperlink layoutX="26.0" layoutY="102.0" text="Settings" />
|
||||||
|
</children>
|
||||||
|
</Pane>
|
Loading…
x
Reference in New Issue
Block a user