Issue
In my Intellij IDEA, I am receiving an error that it "Cannot resolve symbol 'VBox'". I have clearly imported VBox with:
import javafx.scene.layout.VBox
Is there a fix? My current code is below:
package sample;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import javafx.stage.*;
public class Main extends Application {
Scene scene1, scene2;
Stage window;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Label label1 = new Label("This is scene one!");
Button button1 = new Button("Go to scene two!");
button1.setOnAction(event -> window.setScene(scene2));
Vbox layout1 = new VBox(20);
layout1.getChildren().addAll(label1, button1);
}
}
Solution
Wrong: Vbox layout1 = new VBox(20);
Correct: VBox layout1 = new VBox(20);
It's called VBox, not Vbox. Upper/lowercase matters a lot in programming.
Answered By - Nand