JavaFX:不管我写的代码如何,它总是出现空白的“ hello word” GUI

时间:2019-12-18 02:31:23

标签: java user-interface javafx

我写的代码没关系 它总是显示带有“ hello world”标题的空白空白GUI 而我从来没有在我的代码上设置标题或写过“ hello world” 该视频将说明所有内容

https://www.youtube.com/watch?v=JDgKtqfNFfw

这是我的代码:

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application {
    Button button;
    public static void main (String[] args)
    {
        launch(args);
    }
    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("123456");
        button=new Button("Convert");
        StackPane layout = new StackPane();
        layout.getChildren().add(button);
        Scene s= new Scene(layout,300,250);
        primaryStage.setScene(s);
        primaryStage.show();

    }
}

2 个答案:

答案 0 :(得分:1)

根据问题的comment中的建议,您的代码没有问题,因此您应检查正在运行的配置。尝试检查以下内容:

  • Intellij Idea正在加载的Java类
  • 如果与Main.class有所不同,请进行更改

如果没有帮助,请尝试在Intellij Idea中创建没有模板的新项目,并从头开始创建新配置。它肯定会解决您的问题。

答案 1 :(得分:1)

问题解决了!哦,我的坏!现在我明白了。 问题是我忽略了生成的样本<div class="hero-image1"> <div class="hero-text1"> <br/><br/><br/><br/><br/><br/> <img src="icons/[2019-12-05-07-56-32]___Asset-1@4x.png" width="100px"> <h1 style="font-size:60px">Our Vision</h1> <br/> <h2 style="font-size:50px">To simplify the complex.</h2> <!-- <button>Hire me</button> --> </div> </div> <div class="hero-image2"> <div class="hero-text2"> <img src="icons/[2019-12-05-07-56-32]___Asset-2@4x.png" width="100px"> <h1 style="font-size:60px">Our Mission</h1> <h2 style="font-size:50px">We believe lending should be frictionless, secure, and trusted - from the borrower to the secondary market.</h2> <br/> <!-- <button>Hire me</button> --> <table style="width:100%"> <tr align="center"> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-34___Asset-4@4x.png" width="100px"></th> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-35___Asset-5@4x.png" width="100px"></th> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-35___Asset-6@4x.png" width="100px"></th> </tr> <tr align="center"> <td><p style="margin: 0px !important" id="rcorners1">Frictionless</p><p style="margin: 0px !important" id="rcorners2">Easy, fast, efficient, and continuously flowing</p></td> <td><p style="margin: 0px !important" id="rcorners1">Secure</p><p style="margin: 0px !important" id="rcorners2">Protected data, secure platform</p></td> <td><p style="margin: 0px !important" id="rcorners1">Trusted</p><p style="margin: 0px !important" id="rcorners2">Trusted assets, trusted transactions</p></td> </tr> </table> </div> </div> <div class="hero-image3"> <div class="hero-text3"> <br/><br/><br/><br/><br/><br/><br/> <img src="icons/[2019-12-05-07-56-33]___Asset-3@4x.png" width="100px"> <h1 style="font-size:60px">Our Values</h1> <h2 style="font-size:50px">We operate by the following guiding principles and beliefs:</h2> <br/> <!-- <button>Hire me</button> --> <table style="width:100%"> <tr align="center"> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-35___Asset-7@4x.png" width="100px"></th> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-36___Asset-8@4x.png" width="100px"></th> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-36___Asset-9@4x.png" width="100px"></th> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-36___Asset-10@4x.png" width="100px"></th> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-37___Asset-11@4x.png" width="100px"></th> </tr> <tr align="center"> <td><p style="margin: 0px !important" id="rcorners3">Own It</p><p style="margin: 0px !important" id="rcorners4">By solving problems, being responsible, and taking action</p></td> <td><p style="margin: 0px !important" id="rcorners3">Learn, Teach, Grow</p><p style="margin: 0px !important" id="rcorners4">By thinking critically, challenging with respect, and suspending judgment</p></td> <td><p style="margin: 0px !important" id="rcorners3">Elevate and Innovate</p><p style="margin: 0px !important" id="rcorners4">By continually improving and possessing a can-do attitude</p></td> <td><p style="margin: 0px !important" id="rcorners3">Do the Right Thing</p><p style="margin: 0px !important" id="rcorners4">With trust, inclusiveness, dignity, and respect</p></td> <td><p style="margin: 0px !important" id="rcorners3">Think Client First</p><p style="margin: 0px !important" id="rcorners4">By understanding our clients to create value and customers for life</p></td> </tr> </table> </div> </div> <div class="hero-image4"> <div class="hero-text4"> <!-- <h1 style="font-size:50px">I am Jane Doe</h1> <h3>And I'm a Photographer</h3> <button>Hire me</button> --> </div> </div> <div class="hero-image5"> <div class="hero-text5"> <h1 style="font-size:50px">Living Our Vision, Mission, and Values</h1> <h2>How do we live our vision, mission, and values:</h2> <br/> <!-- <button>Hire me</button> --> <table style="width:100%"> <tr> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-37___Asset-12@4x.png" width="100px"></th> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-37___Asset-13@4x.png" width="100px"></th> <th><img src="https://www.eoriginal.com/wp-content/uploads/2019/12/2019-12-05-07-56-38___Asset-14@4x.png" width="100px"></th> </tr> <tr> <td><p><b>With our clients</b></p></td> <td><p><b>With our employees</b></p></td> <td><p><b>As an organization</b></p></td> </tr> </table> </div> </div>,而是手动创建了另一个主类。我一起工作; 当我运行时,IDE将运行示例main而不是我的main。