# only-app-fx **Repository Path**: onlylibrary/only-app-fx ## Basic Information - **Project Name**: only-app-fx - **Description**: JavaFX的主题 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 7 - **Created**: 2018-05-13 - **Last Updated**: 2024-12-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # only-app-fx #### 项目介绍 这是一款javafx的主题,以及 无标题窗口OnlyStage 靠边自动隐藏OnlyWindowAutoHide #### 截图 * 整体效果
* 和原版对比截图


















#### 使用说明 ``` com.onlyxiahui.app only-app-fx 1.0.0 ``` ```Java package demo; import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.VBox; import javafx.stage.Stage; /** * * 只使用css方式,导入css的组件的子组件有效
* Date 2020-06-19 16:33:34
* * @author XiaHui [onlovexiahui@qq.com]
* @since 1.0.0 */ public class CssSample extends Application { @Override public void start(Stage stage) { Scene scene = new Scene(new Group()); scene.getStylesheets().add(CssSample.class.getResource("/com/only/common/css/Only.css").toString()); stage.setTitle("Hello world"); stage.setWidth(450); stage.setHeight(550); Button button = new Button("Hello world"); VBox vbox = new VBox(); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(button); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } } ``` ```Java package demo; import com.sun.javafx.css.StyleManager; import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.VBox; import javafx.stage.Stage; /** * * 全局使用,所有组件都起效果
* Date 2020-06-19 16:36:35
* * @author XiaHui [onlovexiahui@qq.com]
* @since 1.0.0 */ public class GlobalSample extends Application { @Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Hello world"); stage.setWidth(450); stage.setHeight(550); Button button = new Button("Hello world"); VBox vbox = new VBox(); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(button); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); // 此方式需要stage.show();执行后再执行才起效果 StyleManager.getInstance().addUserAgentStylesheet(GlobalSample.class.getResource("/com/only/common/css/Only.css").toString()); } public static void main(String[] args) { launch(args); } } ``` ```Java package demo; import com.onlyxiahui.app.fx.OnlyStage; import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.control.Button; import javafx.scene.layout.VBox; import javafx.stage.Stage; /** * * OnlyStage使用方式,所有OnlyStage内的组件有效
* Date 2020-06-19 16:31:54
* * @author XiaHui [onlovexiahui@qq.com]
* @since 1.0.0 */ public class OnlyStageSample extends Application { OnlyStage onlyStage = new OnlyStage(); @Override public void start(Stage stage) { onlyStage.setTitle("Hello world"); onlyStage.setWidth(450); onlyStage.setHeight(550); Button button = new Button("Hello world"); VBox vbox = new VBox(); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(button); onlyStage.setCenter(vbox); onlyStage.show(); } public static void main(String[] args) { launch(args); } } ```