Java 为什么Intellij不允许我使用VBox类?
在我的Intellij想法中,我收到一个错误,它“无法解析符号‘VBox’”。我已清楚地导入VBox,其中包含:Java 为什么Intellij不允许我使用VBox类?,java,javafx,Java,Javafx,在我的Intellij想法中,我收到一个错误,它“无法解析符号‘VBox’”。我已清楚地导入VBox,其中包含: import javafx.scene.layout.VBox 有办法吗?我目前的代码如下: package sample; import javafx.application.Application; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.layout.VBox; im
import javafx.scene.layout.VBox
有办法吗?我目前的代码如下:
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);
}
}
错误:
Vbox布局1=新的Vbox(20)代码>
正确:VBox布局1=新的VBox(20)代码>
它叫VBox,不是VBox。大写/小写在编程中非常重要。我的帖子中出现错误。。。正如您在底部巨大的代码块中所看到的那样,我在回答中添加了您的代码片段,您在一个地方遗漏了它。@IPSDSILVA您在文章和代码中有错误谢谢。。。愚蠢的错误。。。我错过了。我有两处错误。你抓住了我错过的那个。谢谢@如果可以的话,Nand将在11分钟后接受。这就是给我一个我不得不等待的错误。谢谢你的帮助和澄清!