import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class GridPaneComputeWidthBug extends Application { 

    @Override 
    public void start(Stage primaryStage) { 
        final GridPane gridPane = new GridPane(); 
        gridPane.setGridLinesVisible(true); 
        gridPane.setStyle("-fx-border-color : red;"); 

        final Text text1 = new Text(); 
        text1.setText("TEXT__SPAN___ON___4___Column "); 
        gridPane.add(text1, 0, 0, 4, 1); 

        final Text text2 = new Text(); 
        text2.setText(" col4 "); 
        gridPane.add(text2, 4, 0, 1, 1); 

        gridPane.add(new Text(" col0 "), 0, 1); 

        final Text text3 = new Text(); 
        text3.setText(" col1 "); 
        gridPane.add(text3, 1, 1); 

        gridPane.add(new Text(" col2 "), 2, 1); 

        final Text text4 = new Text(); 
        text4.setText(" SPAN_ON_COL3_4"); 
        gridPane.add(text4, 3, 1, 2, 1); //BUG if SPAN 2 work with span 1 

        final VBox vBox = new VBox(gridPane); 
        vBox.setFillWidth(false); 
        StackPane root = new StackPane(vBox); 

        Scene scene = new Scene(root, 600, 250); 
        primaryStage.setTitle("GridPane bug"); 
        primaryStage.setScene(scene); 
        primaryStage.show(); 
    } 

    /** 
     * @param args the command line arguments 
     */ 
    public static void main(String[] args) { 
        launch(args); 
    } 

} 
