我正在使用javafx制作棒球比赛应用程序。我想在棒球场上展示棒球运动员。但是,有一个白色的盒子限制了玩家并阻挡了棒球场的视野。 如何使用javafx删除此框?
import java.io.File;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class BaseballView extends Application {
@Override
public void start(Stage stage) {
StackPane root = new StackPane();
String image = this.getClass().getResource("baseball_field.jpg")
.toExternalForm();
root.setStyle(" -fx-background-image: url('" + image + "'); "
+ "-fx-background-position: center center; "
+ "-fx-background-repeat: stretch;");
stage.setScene(new Scene(root, 340, 340));
stage.setTitle("Baseball");
ImageView player = new ImageView();
player.setTranslateX(250);
player.setImage(new Image("player.bmp"));
root.getChildren().add(player);
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}