[英]swing javafx application with undecorated frame
我不完全了解這是怎么工作的,如果可以的話,我想解決這個問題。 我試圖擺脫幀退出按鈕,最小化和還原等,以便可以設置自己的按鈕,但是我的程序涉及javafx,並且不允許setUndecorated()方法工作。
import java.awt.Dimension;
import javax.swing.JFrame;
import javafx.application.Application;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Test extends JFrame {
private final int WIDTH = 600;
private final int HEIGHT = 300;
public Test() {
JFXPanel fxpanel = new JFXPanel();
fxpanel.setScene(createScene(this));
add(fxpanel);
setTitle("Frame");
setSize(new Dimension(WIDTH, HEIGHT));
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
setResizable(false);
setLocationRelativeTo(null);
// setUndecorated(true); would go here.. but it doesn't work.
}
private Scene createScene(JFrame frame) {
StackPane root = new StackPane();
Scene scene = new Scene(root, Color.ALICEBLUE);
Text text = new Text();
text.setX(150);
text.setY(100);
text.setFont(new Font(25));
text.setText("Welcome JavaFX!");
root.getChildren().add(text);
return (scene);
}
public static void main(String[] args) {
new Test();
}
}
您必須在setVisible之前調用setUndecorated
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.