I am making a baseball playing application using javafx. I want to display a baseball player on top of a baseball field. However, there is a white box bounding the player and blocking view of the baseball field. How can I remove this box using 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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.