日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

javafx有布局管理器吗_JavaFX技巧17:带有AnchorPane的动画工作台布局

發布時間:2023/12/3 java 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 javafx有布局管理器吗_JavaFX技巧17:带有AnchorPane的动画工作台布局 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

javafx有布局管理器嗎

最近,我不得不為應用程序實現一個布局,其中可以根據用戶是否登錄來隱藏或顯示菜單區和狀態區,并通過滑入/滑出動畫顯示該區域。 以下視頻顯示了實際的布局:

過去,我可能會使用自定義控件和自定義布局代碼來實現這種行為(例如“在外觀中覆蓋layoutChildren()方法”)。 但是這次我的設置有所不同,因為我使用的是Adam Bien的afterburner.fx ,現在我有了FXML和一個控制器類。

那該怎么辦呢? 我決定嘗試使用錨定窗格來實現運氣,并通過時間軸實例更新堆棧窗格上的約束。 約束存儲在堆棧窗格的可觀察屬性圖中。 只要這些限制發生變化,就會自動請求錨定窗格的布局。 如果發生這種情況而沒有任何閃爍,那么我們最終會得到一個很好的平滑動畫。 順便說一句,來自Swing,我總是希望閃爍,但是JavaFX通常不會發生閃爍。

最后,我寫了下面的控制器類來管理錨窗格及其子堆棧窗格。 請注意中間屬性menuPaneLocation和bottomPaneLocation的小技巧。 它們是必需的,因為動畫時間軸可與屬性一起使用。 因此,它會更新這些屬性,并且每當它們更改時,都會應用新的錨定窗格約束。

import static javafx.scene.layout.AnchorPane.setBottomAnchor; import static javafx.scene.layout.AnchorPane.setLeftAnchor; import javafx.animation.KeyFrame; import javafx.animation.KeyValue; import javafx.animation.Timeline; import javafx.beans.property.BooleanProperty; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.fxml.FXML; import javafx.scene.layout.StackPane; import javafx.util.Duration;</code>/*** This presenter covers the top-level layout concepts of the workbench.*/ public class WorkbenchPresenter {@FXML private StackPane topPane;@FXML private StackPane menuPane;@FXML private StackPane centerPane;@FXML private StackPane bottomPane;public WorkbenchPresenter() { }private final BooleanProperty showMenuPane = new SimpleBooleanProperty(this, "showMenuPane", true);public final boolean isShowMenuPane() {return showMenuPane.get(); }public final void setShowMenuPane(boolean showMenu) {showMenuPane.set(showMenu); }/** * Returns the property used to control the visibility of the menu panel. * When the value of this property changes to false then the menu panel will * slide out to the left). * * @return the property used to control the menu panel */ public final BooleanProperty showMenuPaneProperty() {return showMenuPane; }private final BooleanProperty showBottomPane = new SimpleBooleanProperty(this, "showBottomPane", true);public final boolean isShowBottomPane() {return showBottomPane.get(); }public final void setShowBottomPane(boolean showBottom) {showBottomPane.set(showBottom); }/** * Returns the property used to control the visibility of the bottom panel. * When the value of this property changes to false then the bottom panel * will slide out to the left). * * @return the property used to control the bottom panel */ public final BooleanProperty showBottomPaneProperty() {return showBottomPane; }public final void initialize() {menuPaneLocation.addListener(it -> updateMenuPaneAnchors());bottomPaneLocation.addListener(it -> updateBottomPaneAnchors());showMenuPaneProperty().addListener(it -> animateMenuPane());showBottomPaneProperty().addListener(it -> animateBottomPane());menuPane.setOnMouseClicked(evt -> setShowMenuPane(false));centerPane.setOnMouseClicked(evt -> {setShowMenuPane(true);setShowBottomPane(true);});bottomPane.setOnMouseClicked(evt -> setShowBottomPane(false)); }/** The updateMenu/BottomPaneAnchors methods get called whenever the value of* menuPaneLocation or bottomPaneLocation changes. Setting anchor pane* constraints will automatically trigger a relayout of the anchor pane* children.*/private void updateMenuPaneAnchors() {setLeftAnchor(menuPane, getMenuPaneLocation());setLeftAnchor(centerPane, getMenuPaneLocation() + menuPane.getWidth()); }private void updateBottomPaneAnchors() {setBottomAnchor(bottomPane, getBottomPaneLocation());setBottomAnchor(centerPane, getBottomPaneLocation() + bottomPane.getHeight());setBottomAnchor(menuPane,getBottomPaneLocation() + bottomPane.getHeight()); }/* * Starts the animation for the menu pane. */ private void animateMenuPane() {if (isShowMenuPane()) {slideMenuPane(0);} else {slideMenuPane(-menuPane.prefWidth(-1));} }/* * Starts the animation for the bottom pane. */ private void animateBottomPane() {if (isShowBottomPane()) {slideBottomPane(0);} else {slideBottomPane(-bottomPane.prefHeight(-1));} }/** The animations are using the JavaFX timeline concept. The timeline updates* properties. In this case we have to introduce our own properties further* below (menuPaneLocation, bottomPaneLocation) because ultimately we need to* update layout constraints, which are not properties. So this is a little* work-around.*/private void slideMenuPane(double toX) {KeyValue keyValue = new KeyValue(menuPaneLocation, toX);KeyFrame keyFrame = new KeyFrame(Duration.millis(300), keyValue);Timeline timeline = new Timeline(keyFrame);timeline.play(); }private void slideBottomPane(double toY) {KeyValue keyValue = new KeyValue(bottomPaneLocation, toY);KeyFrame keyFrame = new KeyFrame(Duration.millis(300), keyValue);Timeline timeline = new Timeline(keyFrame);timeline.play(); }private DoubleProperty menuPaneLocation = new SimpleDoubleProperty(this, "menuPaneLocation");private double getMenuPaneLocation() {return menuPaneLocation.get(); }private DoubleProperty bottomPaneLocation = new SimpleDoubleProperty(this, "bottomPaneLocation");private double getBottomPaneLocation() {return bottomPaneLocation.get(); } }

以下是此項工作所需的FXML:

<?xml version="1.0" encoding="UTF-8"?><?import java.lang.*?> <?import javafx.scene.layout.*?><AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.workbench.WorkbenchPresenter"><children><StackPane fx:id="bottomPane" layoutX="-4.0" layoutY="356.0" prefHeight="40.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" /><StackPane fx:id="menuPane" layoutY="28.0" prefWidth="200.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="40.0" /><StackPane fx:id="topPane" prefHeight="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /><StackPane fx:id="centerPane" layoutX="72.0" layoutY="44.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="200.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="40.0" /></children> </AnchorPane>

翻譯自: https://www.javacodegeeks.com/2015/02/javafx-tip-17-animated-workbench-layout-anchorpane.html

javafx有布局管理器嗎

總結

以上是生活随笔為你收集整理的javafx有布局管理器吗_JavaFX技巧17:带有AnchorPane的动画工作台布局的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美成人精品一区二区三区在线看 | 激情综合久久 | 91娇羞白丝网站 | 女人扒开腿让男人桶爽 | jizz在线看| 污污视频网站在线 | 精品99视频| 国产人妻一区二区三区四区五区六 | 操操操操操操操操操操 | 在线观看wwww | av中文字幕一区 | 久久久久亚洲av无码专区桃色 | 日日干日日爽 | 国产又黄又骚 | 国产精品美女自拍视频 | 18成人免费观看网站下载 | 撸啊撸在线视频 | 嫩草嫩草嫩草嫩草嫩草 | 国产精品无套 | 日本中文字幕二区 | 美女黄色一级视频 | 国产乱轮视频 | √8天堂资源地址中文在线 欧美精品在线一区二区 | 精品国产乱码 | 成人在线观看网址 | 污污污污污污www网站免费 | 中日韩男男gay无套 人人草人人干 | 在线精品免费视频 | 久久综合加勒比 | 亚欧美在线观看 | 午夜在线播放视频 | 久久久精品在线 | 美女网站免费观看 | 日本a级片视频 | 国产精品aaaa | 国产欧美日韩一区二区三区 | 亚洲国产成人久久 | 国产ts人妖调教重口男 | 欧州一级片 | 色婷婷综合在线 | 男人天堂社区 | 久久久av一区二区三区 | av网在线观看 | 杨幂一区二区三区免费看视频 | 欧美com | 成人片黄网站久久久免费 | 亚洲理论视频 | 人人射 | 国产成人精品在线视频 | 校园伸入裙底揉捏1v1h | 欧美精品免费看 | 一本久道久久综合 | 成人毛片视频免费看 | 乱妇乱女熟妇熟女网站 | 美女一区二区三区视频 | 福利在线视频导航 | 亚洲乱色 | 欧美亚洲国产一区二区三区 | 清冷学长被爆c躁到高潮失禁 | 在线播放精品视频 | 中文字幕一区二区视频 | 中文字幕在线视频观看 | 日本黄页网站免费大全 | 亚洲AV无码精品一区二区三区 | 欧美一区二区三区四区五区六区 | 一区二区免费在线 | 91麻豆网 | 2020亚洲男人天堂 | 亚洲成人免费在线 | 人人澡超碰碰97碰碰碰 | 大桥未久av一区二区三区中文 | 精品视频在线播放 | 毛片2| 日b在线观看| heyzo在线播放 | 久久精品成人 | 国产乱人乱偷精品视频a人人澡 | 伊人77| 成年人看片网站 | 中文字幕成人一区 | 国产激情自拍 | 欧美 日韩 国产 一区 | 国产99对白在线播放 | 美脚の诱脚舐め脚 | 少妇一区二区三区 | 日本电影一区二区三区 | 日本不卡中文字幕 | 色噜噜狠狠一区二区 | 免费国产a| 精品视频在线观看免费 | 印度午夜性春猛xxx交 | 99小视频| 色图av| 亚洲蜜臀av一区二区三区 | 亚洲精品456 | 欧美亚洲视频在线观看 | 亚洲一区二区三区四区五区午夜 | 久久久久久午夜 | 国产精品污www在线观看 |