我用javaFx照着教科书上写了一个简单的窗口,但是运行不了,求解,(代码如下)main那里我不知道怎么运行 20
importjavafx.application.Application;importjavafx.stage.Stage;importjavafx.geometry.P...
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
public class SignInPane extends Application
{
protected Text text1 = new Text(50,50,"Username");
protected BorderPane getPane()
{
HBox paneForButtons = new HBox(20);
Button confirm = new Button("Confirm");
Button cancel = new Button("Cancel");
paneForButtons.getChildren().addAll(confirm,cancel);
paneForButtons.setAlignment(Pos.CENTER);
paneForButtons.setStyle("-fx-border-color: green");
BorderPane pane = new BorderPane();
pane.setBottom(paneForButtons);
Pane paneForText = new Pane();
paneForText.getChildren().add(text1);
pane.setCenter(paneForText);
return pane;
}
@Override
public void start(Stage primaryStage) throws Exception
{
// TODO Auto-generated method stub
Scene scene = new Scene(getPane(),650,500);
primaryStage.setTitle("SIGN IN");
primaryStage.setScene(scene);
primaryStage.show();
}
// public static void main(String[] args)
// {
// start();
//}
} 展开
import javafx.stage.Stage;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
public class SignInPane extends Application
{
protected Text text1 = new Text(50,50,"Username");
protected BorderPane getPane()
{
HBox paneForButtons = new HBox(20);
Button confirm = new Button("Confirm");
Button cancel = new Button("Cancel");
paneForButtons.getChildren().addAll(confirm,cancel);
paneForButtons.setAlignment(Pos.CENTER);
paneForButtons.setStyle("-fx-border-color: green");
BorderPane pane = new BorderPane();
pane.setBottom(paneForButtons);
Pane paneForText = new Pane();
paneForText.getChildren().add(text1);
pane.setCenter(paneForText);
return pane;
}
@Override
public void start(Stage primaryStage) throws Exception
{
// TODO Auto-generated method stub
Scene scene = new Scene(getPane(),650,500);
primaryStage.setTitle("SIGN IN");
primaryStage.setScene(scene);
primaryStage.show();
}
// public static void main(String[] args)
// {
// start();
//}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询