【发布时间】:2015-11-10 23:42:12
【问题描述】:
我开始在 Netbeans 上使用 javaFX 应用程序并尝试示例代码。我面临的问题是,当我从 Netbeans 运行代码时,应用程序运行成功,但按钮排列不正确。但是当我从二进制文件夹中的 jar 文件运行它时,它工作正常。 Netbeans 中有什么解决方法吗?
这是我正在使用的代码:
package guiexperiments;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class GUIExperiments extends Application {
@Override
public void start(Stage primaryStage) {
Button btOK = new Button("OK");
Scene scene = new Scene(btOK, 300, 350);
primaryStage.setTitle("MyJavaFX"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
Stage stage = new Stage(); // Create a new stage
stage.setTitle("Second Stage"); // Set the stage title
// Set a scene with a button in the stage
stage.setScene(new Scene(new Button("New Stage"), 300, 300)); stage.show();
stage.setResizable(false);
}
public static void main(String[] args) {
Application.launch(args);
}
}
抱歉,我无法发布图片,因为我需要 10 个声望点才能发布图片……呃。
【问题讨论】:
-
您使用的是什么版本的网络豆? Java 版本?
-
添加您要上传的图片链接,我们中的某个人会为您完成...
标签: java button layout netbeans javafx