TabPane_ImageView1
  • Adding Image in a tab
Code:

package javafxtemplate1;
//Grid_Transform1.htm
import javafx.application.Application;
import javafx.beans.value.ObservableValue;
import javafx.event.Event;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;


/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
@Override
public void start(Stage primaryStage) {
Label label1 = new Label("Tabs Line ups");
Slider slider = new Slider(0, 1, 0.0);
ImageView iv1 = new ImageView(new Image(
JavaFXTemplate1.class.getResourceAsStream("disk2.jpg")));
// image within a stack pane
StackPane imageContainer = new StackPane();
imageContainer.getChildren().addAll(new Rectangle(400, 200, Color.CORNFLOWERBLUE), iv1);
HBox hbox = new HBox();
hbox.setPadding(new Insets(15, 12, 15, 12));
hbox.setSpacing(20);
hbox.setStyle("-fx-background-color:WHEAT;");
Tab tab1 = new Tab("Tab1");Tab tab2 = new Tab("Tab2");
//tab1.setContent(new Rectangle(400,200, Color.LIGHTSTEELBLUE));
tab1.setContent(imageContainer);
tab2.setContent(new Rectangle(400,200, Color.LIGHTSEAGREEN));
TabPane tabPane = new TabPane();
tabPane.getTabs().addAll(tab1,tab2);
hbox.getChildren().addAll(label1,tabPane);
Scene scene = new Scene(hbox, 550,300);
primaryStage.setScene(scene);
primaryStage.setTitle("Progressbar Indicator");
primaryStage.show();
}

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

}
 

 

Displays: