wordpress无法开启多站点seo短视频新地址在哪里

当前位置: 首页 > news >正文

wordpress无法开启多站点,seo短视频新地址在哪里,网站开发工程师 课程大纲,九江市建设工程门户网站JavaFX 加载 fxml 文件主要有两种方式#xff0c;第一种方式通过 FXMLLoader 类直接加载 fxml 文件#xff0c;简单直接#xff0c;但是有些控件目前还不知道该如何获取#xff0c;所以只能显示#xff0c;目前无法处理。第二种方式较为复杂#xff0c;但是可以使用与 fx…JavaFX 加载 fxml 文件主要有两种方式第一种方式通过 FXMLLoader 类直接加载 fxml 文件简单直接但是有些控件目前还不知道该如何获取所以只能显示目前无法处理。第二种方式较为复杂但是可以使用与 fxml 文件对应的 *Controller 类可以操作 fxml 文件中的所有控件。现将两种方式介绍如下 方式一 创建 fxml 的 UI 文件将 fxml 文件放置到对应位置FXMLLoader 加载文件显示 fxml 文件 ?xml version1.0 encodingUTF-8??import java.lang.? ?import java.util.? ?import javafx.scene.? ?import javafx.scene.control.? ?import javafx.scene.layout.*?VBox maxHeight-Infinity maxWidth-Infinity minHeight-Infinity minWidth-Infinity xmlnshttp://javafx.com/javafx/8 xmlns:fxhttp://javafx.com/fxml/1childrenButton fx:idownedNone alignmentCENTER mnemonicParsingfalse textOwned None /Button fx:idnonownedNone mnemonicParsingfalse textNon-owned None /Button fx:idownedWindowModal mnemonicParsingfalse textOwned Window Modal /Button mnemonicParsingfalse textButton /Button mnemonicParsingfalse textButton //children /VBox UI 显示 java加载 fxml 文件 package ch04;import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Cursor; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.VBox; import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.Window;/* author qiaowei* version 1.0* package ch04* date 2020/5/24* description/ public class LoadFXMLTest extends Application {public static void main(String[] args) {launch(args);}Overridepublic void start(Stage primaryStage) {try {useFXMLLoader(primaryStage);} catch (Exception ex) {ex.printStackTrace();}}/**class LoadFXMLTestdate 2020/5/24author qiaoweiversion 1.0brief 使用FXMLLoader加载fxml文件并生成相应的java类param primaryStage Application创建的Stage实例/public void useFXMLLoader(Stage primaryStage) throws Exception {Parent root FXMLLoader.load(getClass().getResource(/sources/StageModalityWindow.fxml));// 根据控件在窗体控件的添加顺序编号获取// Button ownedNone (Button) ((VBox) root).getChildren().get(0);Button ownedNone (Button) root.lookup(#ownedNone);ownedNone.setOnAction(e - resetWindowTitle(primaryStage, hello ownedNone));Button ownedWindowModal (Button) root.lookup(#ownedWindowModal);ownedWindowModal.setOnAction(e - resetWindowTitle(primaryStage, ownedWindowModal));int width ((int) ((VBox) root).getPrefWidth());int height ((int) ((VBox) root).getPrefHeight()); //Scene scene new Scene(root, width, height); // Scene scene new Scene(root); // Button ownedNoneButton ((VBox) root).getChildren().get(1);primaryStage.setTitle(StageModality);primaryStage.setScene(scene);primaryStage.show();}/class StageModalityAppdate 2020/3/6author qiaoweiversion 1.0description 根据窗口拥有者和模式设置窗口状态param owner 窗口的父控件param modality 窗口的模式*/private void showDialog(Window owner, Modality modality) {// Create a new stage with specified owner and modalityStage stage new Stage();stage.initOwner(owner);stage.initModality(modality);Label modalityLabel new Label(modality.toString());Button closeButton new Button(Close);closeButton.setOnAction(e - stage.close());VBox root new VBox();root.getChildren().addAll(modalityLabel, closeButton);Scene scene new Scene(root, 200, 100);// 设置鼠标在scene的显示模式scene.setCursor(Cursor.HAND);stage.setScene(scene);stage.setTitle(A Dialog Box);stage.show();}private void resetWindowTitle(Stage stage, String title) {stage.setTitle(title);} } 根据 fxml 中控件的 “fx:id” 属性获取控件并添加触发事件。通过 button 修改窗体的 title 注意两点 fxml 的存放路径不同位置加载 String 不同。fxml 加载后返回的是 root 实例需要放置到 sence 实例中再显示。在通过 fxml 中控件的 id 返回控件时id 前要加 #字符。 第二种方式 创建 fxml 文件在 fxml 文件的顶层控件设置 “fx:controller”属性值 “完整的包路径.*Controller” 在完整的包路径下创建 Controller 类在 fxml 文件中定义的控件和方法前都加 “FXML”注意两个文件中的对应控件、方法名称必须保持一致。 注意Controller 类在这里只继承 Objec这样其中的控件都自动绑定到 fxml 中的控件不会出现控件为 null 的情况。退出程序按钮。不添加 FXML 注解系统认为时类自己添加的控件不会与 fxml 文件中同名控件绑定系统不会自动初始化值为 null添加 FXML 注解系统会自动绑定到 fxml 文件中的同名控件会自动给初始化为 MenuItem 的实例。注意字段与方法的区别如果在 fxml 中定义方法在 java 文件中必须有同名的方法而且方法前要加 FXML 注释。 示例如下创建一个有 menuBar、menuItem 的窗体在 fxml 中定义 menuItem 的 id 和 Action在 **Controller 中操作控件 menuItem 和 Action。 fmxl 文件其中 openItem 没有设置 onActioncloseItem 设置 onAction注意之后的两种处理方式。 ?xml version1.0 encodingUTF-8??import javafx.scene.control.? ?import javafx.scene.layout.*?AnchorPane prefHeight400.0 prefWidth600.0 xmlnshttp://javafx.com/javafx/10.0.2-internal xmlns:fxhttp://javafx.com/fxml/1 fx:controllerch06.VHFFrameControllerchildrenMenuBar fx:idmenuBar layoutY2.0 AnchorPane.topAnchor2.0menusMenu mnemonicParsingfalse textFileitemsMenuItem fx:idopenItem mnemonicParsingfalse textOpen /MenuItem fx:idcloseItem mnemonicParsingfalse onAction#exitApp textExit //items/MenuMenu mnemonicParsingfalse textEdititemsMenuItem mnemonicParsingfalse textDelete //items/MenuMenu mnemonicParsingfalse textHelpitemsMenuItem mnemonicParsingfalse textAbout //items/Menu/menus/MenuBarSeparator prefWidth200.0 //children /AnchorPane 对应的 ***Controller 类openItem 通过在 setStage 方法中绑定 setOnAction不能在构造函数中进行绑定只能通过其它方法绑定closeItem 通过 fxml 文件中的设置直接绑定了 exitApp 方法注两个 MenuItem 控件通过不同的方法进行动作绑定一个在 fxml 文件中绑定一个在类文件中绑定 注意fxml 文件中设置的控件、方法在 Controller 类中要通过 “FXML” 标识方法、字段在绑定且方法、字段名称完全一致。 package ch06;import javafx.fxml.FXML; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.stage.Stage;/package ch06 file VHFFrameController.javadate 2020/5/27author qiaoweiversion 1.0description 与VHFFFrame.fxml文件对应的Controller类/ public class VHFFrameController {public VHFFrameController() {operator Operator.instance();}/class VHFFrameControllerdate 2020/5/27author qiaoweiversion 1.0brief 打开文件选择窗口*/ // FXMLpublic void openChooser() {if (isStage()) {operator.openFile(primaryStage); }}/class VHFFrameControllerdate 2020/5/27author qiaoweiversion 1.0brief 设置primaryStage字段实例当字段已经设置过跳过设置步骤param primaryStage 从主程序传来的主primaryStage实例/public void setStage(Stage primaryStage) {if ( !isStage()) {this.primaryStage primaryStage;}openItem.setOnAction(e - openChooser());}/**class VHFFrameControllerdate 2020/5/27author qiaoweiversion 1.0brief 退出程序/FXMLprivate void exitApp() {operator.exitApp();}/class VHFFrameControllerdate 2020/5/27author qiaoweiversion 1.0brief 判断primaryStage实例是否为null为null时返回false反之返回truereturn true primaryStage不为null反之返回false*/private boolean isStage() {boolean flag false;if (null ! primaryStage) {flag true;} else {flag false;}return flag;}FXMLprivate MenuItem openItem;FXMLprivate MenuItem closeItem;FXMLprivate MenuBar menuBar;private static Operator operator;private Stage primaryStage; } 具体操作类 Operator实现退出程序打开 FileChooser 窗体两个功能 package ch06;import javafx.application.Platform; import javafx.stage.FileChooser; import javafx.stage.Stage;import java.io.File;/* author qiaowei* version 1.0* package ch06* date 2020/5/27* description/ public class Operator {private Operator() {}public static Operator instance() {if (null OPERATOR) {OPERATOR new Operator();}return OPERATOR;}public void openFile(Stage stage) {FileChooser chooser new FileChooser();File file chooser.showOpenDialog(stage);}public void exitApp() {Platform.exit();}private static Operator OPERATOR null; } JavaFX 运行类 package ch06;import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage;/** author qiaowei* version 1.0* package ch06* date 2020/5/27* description/ public class VHFApp extends Application {public static void main(String[] args) {try {Application.launch(VHFApp.class, args);} catch (Exception ex) {ex.printStackTrace();}}Overridepublic void start(Stage primaryStage) throws Exception {FXMLLoader fxmlLoader new FXMLLoader(getClass().getResource(/sources/VHFFrame.fxml));Parent root fxmlLoader.load(); // Parent root
// FXMLLoader.load(getClass().getResource(/sources/VHFFrame.fxml));int width ((int) ((AnchorPane) root).getPrefWidth());int height ((int) ((AnchorPane) root).getPrefHeight());Scene scene new Scene(root, width, height);primaryStage.setTitle(VHFApplication);primaryStage.setScene(scene);VHFFrameController controller fxmlLoader.getController();controller.setStage(primaryStage);primaryStage.show();}// private static VHFFrameController controller new VHFFrameController(); } 实现如下 示例 2 文件树图 fxml 文件指定对应的 Controller 文件对控件 exitItem 制定了对应的方法 exitApplication。 ?xml version1.0 encodingUTF-8?!–Copyright © 2015, 2019, Gluon and/or its affiliates.All rights reserved. Use is subject to license terms.This file is available and licensed under the following license:Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met:- Redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclaimer.- Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer inthe documentation and/or other materials provided with the distribution.- Neither the name of Oracle Corporation nor the names of itscontributors may be used to endorse or promote products derivedfrom this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORSAS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOTLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHTOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANYTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. –?import javafx.scene.control.Menu? ?import javafx.scene.control.MenuBar? ?import javafx.scene.control.MenuItem? ?import javafx.scene.control.SeparatorMenuItem? ?import javafx.scene.control.TextArea? ?import javafx.scene.layout.AnchorPane? ?import javafx.scene.layout.VBox?VBox prefHeight400.0 prefWidth640.0 xmlnshttp://javafx.com/javafx/17 xmlns:fxhttp://javafx.com/fxml/1 fx:controllerui.MainWindowControllerchildrenMenuBar VBox.vgrowNEVERmenusMenu mnemonicParsingfalse textFileitemsMenuItem mnemonicParsingfalse textNew /MenuItem fx:idopenItem mnemonicParsingfalse textOpen… /Menu mnemonicParsingfalse textOpen Recent /SeparatorMenuItem mnemonicParsingfalse /MenuItem mnemonicParsingfalse textClose /MenuItem mnemonicParsingfalse textSave /MenuItem mnemonicParsingfalse textSave As… /MenuItem mnemonicParsingfalse textRevert /SeparatorMenuItem mnemonicParsingfalse /MenuItem mnemonicParsingfalse textPreferences… /SeparatorMenuItem mnemonicParsingfalse /MenuItem fx:idexitItem mnemonicParsingfalse onAction#exitApplication textQuit //items/MenuMenu mnemonicParsingfalse textEdititemsMenuItem mnemonicParsingfalse textUndo /MenuItem mnemonicParsingfalse textRedo /SeparatorMenuItem mnemonicParsingfalse /MenuItem mnemonicParsingfalse textCut /MenuItem mnemonicParsingfalse textCopy /MenuItem mnemonicParsingfalse textPaste /MenuItem mnemonicParsingfalse textDelete /SeparatorMenuItem mnemonicParsingfalse /MenuItem mnemonicParsingfalse textSelect All /MenuItem mnemonicParsingfalse textUnselect All //items/MenuMenu mnemonicParsingfalse textHelpitemsMenuItem mnemonicParsingfalse textAbout MyHelloApp //items/Menu/menus/MenuBarAnchorPane maxHeight-1.0 maxWidth-1.0 prefHeight-1.0 prefWidth-1.0 VBox.vgrowALWAYSchildrenTextArea layoutX178.0 layoutY73.0 prefHeight200.0 prefWidth200.0 AnchorPane.bottomAnchor0.0 AnchorPane.leftAnchor0.0 AnchorPane.rightAnchor0.0 AnchorPane.topAnchor0.0 //children/AnchorPane/children /VBox 对应的 Controller在退出程序过程中对 openItem 按钮是否为 null 进行测试有 FXML 注解时openItem 被自动绑定实例不为 null当注释调 FXML 注解后openItem 没有自动绑定实例为 null。如果要在 Controller 类中对控件进行操作可以实现 initialize 方法和 FXML 注解。这样保证控件已经绑定实例可以对比 initialize 和 setupAttributes 方法两者中 openItem 控件的情况。FXMLLoader 首先调用默认构造函数然后调用 initialize 方法从而创建相应控制器的实例。首先调用构造函数然后填充所有 FXML 带注释的字段最后调用 initialize ()。因此构造函数无法访问引用在 fxml 文件中定义的组件的 FXML 注解字段而 initialize 方法可以访问这些注解字段。 package ui;import javafx.application.Platform; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.MenuItem;import java.net.URL; import java.util.ResourceBundle;/**************************************************************************************************
copyright 2003-2022* package ui* file MainWindowController.java* date 2022/5/2 22:54* author qiao wei* version 1.0* brief MainWindow.fxml的绑定类。* history ***********************************************************************************************/ public class MainWindowController {public MainWindowController() {setupAttributes();}FXMLpublic void initialize() {if (null ! openItem) {openItem.setOnAction(e - exitApplication());}}public void setupAttributes() {if (null ! openItem) {openItem.setOnAction(e - openFile());}}private void openFile() {}FXMLprivate void exitApplication() {if (null ! openItem) {System.out.println(测试FXML注释作用);}Platform.exit();}FXMLprivate MenuItem openItem;/******************************************************************************************** date 2022/5/2 22:48* author qiao wei* brief 退出程序按钮。不添加FXML注解系统认为时类自己添加的控件不会与fxml文件中同名控件绑定系统* 不会自动初始化值为null添加FXML注解系统会自动绑定到fxml文件中的同名控件会自动给初始化* 为MenuItem的实例。注意字段与方法的区别如果在fxml中定义方法在java文件中必须有同名的方法而且* 方法前要加FXML注释。*******************************************************************************************/FXMLprivate MenuItem exitItem; } 启动类 import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.geometry.Rectangle2D; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Screen; import javafx.stage.Stage; import ui.MainWindowController;/********************************************************************************************Copyright 2003-2022package PACKAGE_NAMEdate 2022/5/2author qiao weiversion 1.0brief TODOhistory**********************************************************************************************/ public class Main extends Application {public static void main(String[] args) {try {Application.launch(Main.class, args);} catch (Exception exception) {exception.printStackTrace();}}Overridepublic void start(Stage primaryStage) throws Exception {FXMLLoader fxmlLoader new FXMLLoader(getClass().getResource(/fxml/MainWindow.fxml));Parent root fxmlLoader.load(); // MainWindowController controller fxmlLoader.getController();Rectangle2D rectangle2D Screen.getPrimary().getBounds();// 获取窗体左上角初始坐标double xPosition rectangle2D.getWidth() / 5;double yPosition rectangle2D.getHeight() / 5;// 获取窗体尺寸int width (int) rectangle2D.getWidth() * 2 / 3;int height (int) rectangle2D.getHeight() * 2 / 3;// 设置窗体起始坐标、尺寸primaryStage.setScene(new Scene(root, width, height));primaryStage.setX(xPosition);primaryStage.setY(yPosition);primaryStage.setTitle(Radar Track Application);primaryStage.show();} } 运行结果