Skip to content

Commit

Permalink
Fix JavaFX for real this time
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Jan 7, 2024
1 parent 8b93f0f commit 3db5827
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 3 deletions.
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ base {
version = project.maven_version ?: rootProject.maven_version
}

sourceSets {
javaFxStub // Java 11+ does not include JavaFX anymore, so the JavaFX stubs are needed for the compiler
}

repositories {
mavenCentral()
}

dependencies {
compileOnly "org.jetbrains:annotations:24.1.0"
["base", "graphics", "web", "swing"].each {
compileOnly "org.openjfx:javafx-$it:11:win" // Hardcoding the platform is not a problem since this is a compileOnly dependency
}
compileOnly sourceSets.javaFxStub.output

api "org.apache.httpcomponents:httpclient:4.5.14"
api "com.google.code.gson:gson:2.10.1"
Expand Down
24 changes: 24 additions & 0 deletions src/javaFxStub/java/javafx/application/Platform.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* This file is part of MinecraftAuth - https://github.com/RaphiMC/MinecraftAuth
* Copyright (C) 2022-2024 RK_01/RaphiMC and contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package javafx.application;

public class Platform {

public static native void runLater(final Runnable runnable);

}
24 changes: 24 additions & 0 deletions src/javaFxStub/java/javafx/beans/value/ChangeListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* This file is part of MinecraftAuth - https://github.com/RaphiMC/MinecraftAuth
* Copyright (C) 2022-2024 RK_01/RaphiMC and contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package javafx.beans.value;

public interface ChangeListener<T> {

void changed(final ObservableValue<? extends T> observable, final T oldValue, final T newValue);

}
24 changes: 24 additions & 0 deletions src/javaFxStub/java/javafx/beans/value/ObservableValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* This file is part of MinecraftAuth - https://github.com/RaphiMC/MinecraftAuth
* Copyright (C) 2022-2024 RK_01/RaphiMC and contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package javafx.beans.value;

public interface ObservableValue<T> {

void addListener(final ChangeListener<? super T> listener);

}
28 changes: 28 additions & 0 deletions src/javaFxStub/java/javafx/embed/swing/JFXPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of MinecraftAuth - https://github.com/RaphiMC/MinecraftAuth
* Copyright (C) 2022-2024 RK_01/RaphiMC and contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package javafx.embed.swing;

import javafx.scene.Scene;

import javax.swing.*;

public class JFXPanel extends JComponent {

public native void setScene(final Scene scene);

}
21 changes: 21 additions & 0 deletions src/javaFxStub/java/javafx/scene/Parent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* This file is part of MinecraftAuth - https://github.com/RaphiMC/MinecraftAuth
* Copyright (C) 2022-2024 RK_01/RaphiMC and contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package javafx.scene;

public abstract class Parent {
}
25 changes: 25 additions & 0 deletions src/javaFxStub/java/javafx/scene/Scene.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* This file is part of MinecraftAuth - https://github.com/RaphiMC/MinecraftAuth
* Copyright (C) 2022-2024 RK_01/RaphiMC and contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package javafx.scene;

public class Scene {

public Scene(final Parent root, final double width, final double height) {
}

}
30 changes: 30 additions & 0 deletions src/javaFxStub/java/javafx/scene/web/WebEngine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of MinecraftAuth - https://github.com/RaphiMC/MinecraftAuth
* Copyright (C) 2022-2024 RK_01/RaphiMC and contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package javafx.scene.web;

import javafx.beans.value.ObservableValue;

public final class WebEngine {

public native void setUserAgent(final String value);

public native void load(final String url);

public native ObservableValue<String> locationProperty();

}
28 changes: 28 additions & 0 deletions src/javaFxStub/java/javafx/scene/web/WebView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of MinecraftAuth - https://github.com/RaphiMC/MinecraftAuth
* Copyright (C) 2022-2024 RK_01/RaphiMC and contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package javafx.scene.web;

import javafx.scene.Parent;

public final class WebView extends Parent {

public native void setContextMenuEnabled(final boolean value);

public native WebEngine getEngine();

}

0 comments on commit 3db5827

Please sign in to comment.