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");
});
}
}
公告版位
需要找什麼嗎? 左邊分類或許可以幫助你...
- Sep 23 Wed 2015 16:40
JavaFX Button Image
全站熱搜
留言列表