How to create tabs with icons in JavaFX

后端 未结 3 440
抹茶落季
抹茶落季 2021-02-04 12:04

I want to create tabs panel with icons similar to the Firefox configuration panel with JavaFX:

\"enter

3条回答
  •  渐次进展
    2021-02-04 12:35

    How to add image directly from image url:

              Tab tab = new Tab();
              tab.setGraphic(buildImage("patch/to/image");
    
        // Helper method to create image from image patch
        private static ImageView buildImage(String imgPatch) {
                Image i = new Image(imgPatch);
                ImageView imageView = new ImageView();
                //You can set width and height
                imageView.setFitHeight(16);
                imageView.setFitWidth(16);
                imageView.setImage(i);
                return imageView;
            }
    

提交回复
热议问题