我正在使用jxbrowser使用下面的代码。它带有一个默认的关闭按钮。我正在尝试是否可以有一个最小化按钮也适用于标题栏
Browser browser= getEngine().newBrowser(); BrowserView view = new BrowserView(browser); final JPanel panel = new JPanel(new BorderLayout()); panel.add(view, BorderLayout.CENTER);
Browser browser= getEngine().newBrowser();
BrowserView view = new BrowserView(browser);
final JPanel panel = new JPanel(new BorderLayout());
panel.add(view, BorderLayout.CENTER);
字符串
gcmastyq1#
我会说你应该尝试使用自定义标题栏和处理自己的最小化行动
import javafx.application.Application;import javafx.scene.Scene;import javafx.scene.control.Button;import javafx.scene.layout.HBox;import javafx.scene.layout.Priority;import javafx.scene.layout.VBox;import javafx.stage.Stage;import javafx.stage.StageStyle;import com.teamdev.jxbrowser.browser.Browser;import com.teamdev.jxbrowser.view.javafx.BrowserView;public class CustomTitleBarSample extends Application { @Override public void start(Stage primaryStage) { primaryStage.initStyle(StageStyle.UNDECORATED); Browser browser = Browser.newInstance(); BrowserView view = new BrowserView(browser); Button minimizeButton = new Button("-"); minimizeButton.setOnAction(event -> primaryStage.setIconified(true)); HBox titleBar = new HBox(); titleBar.getChildren().addAll(minimizeButton); VBox root = new VBox(); root.getChildren().addAll(titleBar, view); VBox.setVgrow(view, Priority.ALWAYS); Scene scene = new Scene(root, 800, 600); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); }}
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import com.teamdev.jxbrowser.browser.Browser;
import com.teamdev.jxbrowser.view.javafx.BrowserView;
public class CustomTitleBarSample extends Application {
@Override
public void start(Stage primaryStage) {
primaryStage.initStyle(StageStyle.UNDECORATED);
Browser browser = Browser.newInstance();
Button minimizeButton = new Button("-");
minimizeButton.setOnAction(event -> primaryStage.setIconified(true));
HBox titleBar = new HBox();
titleBar.getChildren().addAll(minimizeButton);
VBox root = new VBox();
root.getChildren().addAll(titleBar, view);
VBox.setVgrow(view, Priority.ALWAYS);
Scene scene = new Scene(root, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
1条答案
按热度按时间gcmastyq1#
我会说你应该尝试使用自定义标题栏和处理自己的最小化行动
字符串