【发布时间】:2016-03-29 03:49:12
【问题描述】:
我正在尝试用按钮制作一个透明的场景和舞台,但它似乎只适用于文本。 这是我的简单代码
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class TransparentStage extends Application {
@Override
public void start(Stage stage) {
stage.initStyle(StageStyle.TRANSPARENT);
Text text = new Text("Transparent!");
text.setFont(new Font(40));
//Button button = new Button("btn");
VBox box = new VBox();
box.getChildren().add(text);
//box.getChildren().add(button);
final Scene scene = new Scene(box,300, 300);
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
但如果我取消注释按钮,结果将是here
它看起来不再透明,但它只是底涂层。 那么透明不适用于按钮吗? 如果我应该添加一个按钮怎么办? 谢谢。
【问题讨论】: