javaFx 简单api

废话不说,都在代码里了

package com.assinfo.demo.com.assinfo.auth;


import javafx.application.Application;
import javafx.application.ConditionalFeature;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Screen;
import javafx.stage.Stage;

public class Demo extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void init() throws Exception {
        super.init();
    }

    @Override
    public void stop() throws Exception {
        super.stop();
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("javaFX");
        primaryStage.getIcons().add(new Image("/icon/icon.png"));

        primaryStage.setOpacity(0.5);//设置透明度
        primaryStage.setX(500);
        primaryStage.setY(500);
        primaryStage.setAlwaysOnTop(true);

//        primaryStage.yProperty().addListener(new ChangeListener() {
//            @Override
//            public void changed(ObservableValue observable, Number oldValue, Number newValue) {
//                System.out.println("窗口位置"+newValue);
//            }
//        });
//        Platform.runLater(new Runnable() {
//            @Override
//            public void run() {
//
//                System.out.println("run方法是什么"+Thread.currentThread().getName());//获取在线程的任务
//                System.out.println("dasdads");
//            }
//        });
//        Platform.setImplicitExit(false);
//         Platform.isSupported(ConditionalFeature.FXML);
//        Platform.exit();
//          Screen screen=Screen.getPrimary();
//
//                Rectangle2D rec1=screen.getBounds();
//                Rectangle2D rec2=screen.getBounds();
//        System.out.println();



//        primaryStage.setIconified(true);//设置最小化
//        primaryStage.setMaximized(true);//设置最小化
//        primaryStage.setWidth(500);
//        primaryStage.setHeight(500);
//        primaryStage.setResizable(false);//设置不可改变的窗口
//        primaryStage.heightProperty().addListener(new ChangeListener() {
//            @Override
//            public void changed(ObservableValue observable, Number oldValue, Number newValue) {
//                System.out.println(newValue.doubleValue());
//            }
//        });
//        primaryStage.setFullScreen(true);
//        primaryStage.setScene(new Scene(new Group()));//设置全屏
        primaryStage.show();
//        primaryStage.close();//窗口关闭
    }

}

唉,亲测能用

你可能感兴趣的:(javaFx 简单api)