http://www.softicons.com/game-icons/super-mario-icons-by-sandro-pereira

https://colorlib.com/wp/free-flat-social-media-icons-sets/


import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Test extends Application {

    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Load Image");

        StackPane sp = new StackPane();
//        Image img = new Image("file:///home/loli/B.jpg");
        Image img = new Image(Test.class.getResourceAsStream("A.png"));
        ImageView imgView = new ImageView(img);
        
        imgView.setFitHeight(32);
        imgView.setFitWidth(32);
        
        Scene scene = new Scene(sp);
        primaryStage.setScene(scene);
        primaryStage.show();

        Button button3 = new Button("Accept", imgView);
        sp.getChildren().add(button3);

        button3.setOnAction((ActionEvent event) -> {
            System.out.println("ok");
        });

    }

}




創作者介紹
創作者 黃彥霖 的頭像
黃彥霖

彥霖 實驗筆記

黃彥霖 發表在 痞客邦 留言(0) 人氣()