javaFx netbean 初始化的工程

来源:互联网 发布:黄牛用抢票软件 编辑:程序博客网 时间:2024/06/06 15:50
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package hello;import javafx.application.Application;import javafx.fxml.FXMLLoader;import javafx.scene.Parent;import javafx.scene.Scene;import javafx.stage.Stage;/** * * @author Administrator */public class Hello extends Application {        @Override    public void start(Stage stage) throws Exception {        Parent root = FXMLLoader.load(getClass().getResource("TakeThis.fxml"));                Scene scene = new Scene(root);                stage.setScene(scene);        stage.show();    }    /**     * The main() method is ignored in correctly deployed JavaFX application.     * main() serves only as fallback in case the application can not be     * launched through deployment artifacts, e.g., in IDEs with limited FX     * support. NetBeans ignores main().     *     * @param args the command line arguments     */    public static void main(String[] args) {        launch(args);    }}


 

 

<?xml version="1.0" encoding="UTF-8"?><?import java.lang.*?><?import java.util.*?><?import javafx.scene.*?><?import javafx.scene.control.*?><?import javafx.scene.layout.*?><AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="hello.TakeThisController">    <children>        <Button layoutX="126" layoutY="90" text="Click Me!" onAction="#handleButtonAction" fx:id="button" />        <Label layoutX="126" layoutY="120" minHeight="16" minWidth="69" fx:id="label" />    </children></AnchorPane>


 

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package hello;import java.net.URL;import java.util.ResourceBundle;import javafx.event.ActionEvent;import javafx.fxml.FXML;import javafx.fxml.Initializable;import javafx.scene.control.Label;/** * * @author Administrator */public class TakeThisController implements Initializable {        @FXML    private Label label;        @FXML    private void handleButtonAction(ActionEvent event) {        System.out.println("You clicked me!");        label.setText("Hello World!");    }        @Override    public void initialize(URL url, ResourceBundle rb) {        // TODO    }    }


 

原创粉丝点击