我正在上第二堂Java课,我的教授告诉我要使用Java博士。我们已经开始学习GUI,并且他给了我们一些示例代码作为示例:
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
import javafx.stage.*;
import javafx.collections.*;
public class HelloWorldMain extends Application{
public void start(Stage primaryStage){
FlowPane pane = new FlowPane();
// put all controls on 'pane'
Label lblHello = new Label("Hello");
pane.getChildren().add(lblHello);
Button btnHello = new Button("Hello World");
pane.getChildren().add(btnHello);
TextField txtHello = new TextField("Hello");
pane.getChildren().add(txtHello);
PasswordField pass = new PasswordField();
pane.getChildren().add(pass);
CheckBox cbHello = new CheckBox("Hello");
pane.getChildren().add(cbHello);
RadioButton rbMale= new RadioButton("Male");
RadioButton rbFemale = new RadioButton("Female");
pane.getChildren().add(rbMale);
pane.getChildren().add(rbFemale);
ToggleGroup group = new ToggleGroup();
rbMale.setToggleGroup(group);
rbFemale.setToggleGroup(group);
ChoiceBox cbColors = new ChoiceBox();
cbColors.setItems(FXCollections.observableArrayList("Red", "Green", "Blue"));
pane.getChildren().add(cbColors);
Scene scene = new Scene(pane, 300, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
}
但是,当我尝试在Java中运行它时,出现以下错误: 静态错误:此类没有接受String []的静态void main方法。
教授无法帮助我,我也看不到这个确切问题的答案。任何帮助表示赞赏!