增加提示框
This commit is contained in:
parent
c7c27d785a
commit
c547a29b46
@ -168,6 +168,7 @@ public class ApplicationManager {
|
||||
RootRightSideBarVerticalBoxManager.getInstance().initRootRightSideBarVerticalBox();
|
||||
// 初始化根布局
|
||||
RootBorderPaneManager.getInstance().initRootBorderPane();
|
||||
|
||||
}
|
||||
|
||||
public Pane getRoot() {
|
||||
|
||||
@ -43,5 +43,6 @@ public class RootBorderPaneManager {
|
||||
rootBorderPane.setTopComponent(RootTopBorderPane.getInstance());
|
||||
// 主界面的下面,底部边栏
|
||||
rootBorderPane.setBottomComponent(RootBottomSideBarVerticalBox.getInstance());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
package org.jcnc.jnotepad.views.manager;
|
||||
|
||||
import atlantafx.base.controls.Notification;
|
||||
import atlantafx.base.theme.Styles;
|
||||
import atlantafx.base.util.Animations;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.util.Duration;
|
||||
import org.jcnc.jnotepad.exception.AppException;
|
||||
import org.jcnc.jnotepad.views.root.RootBorderPane;
|
||||
|
||||
@ -15,7 +23,7 @@ import org.jcnc.jnotepad.views.root.RootBorderPane;
|
||||
public class RootManager {
|
||||
|
||||
private static RootManager instance = null;
|
||||
|
||||
StackPane rootStackPane;
|
||||
/**
|
||||
* 主布局
|
||||
*/
|
||||
@ -65,11 +73,42 @@ public class RootManager {
|
||||
* @param scene 与视图相关联的 JavaFX 场景。
|
||||
*/
|
||||
public void initScreen(Scene scene) {
|
||||
rootStackPane = new StackPane();
|
||||
|
||||
// 创建主界面布局
|
||||
root = new BorderPane();
|
||||
BorderPane root = new BorderPane();
|
||||
root.setCenter(RootBorderPane.getInstance());
|
||||
|
||||
scene.setRoot(root);
|
||||
rootStackPane.getChildren().addAll(root);
|
||||
scene.setRoot(rootStackPane);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 将提示框添加到 StackPane 中。
|
||||
*
|
||||
* @param stackPane 要添加提示框的 StackPane。
|
||||
* @param msg 要显示的提示框。
|
||||
*/
|
||||
public void addNotificationToStackPane(StackPane stackPane, Notification msg) {
|
||||
msg.getStyleClass().addAll(Styles.ACCENT, Styles.ELEVATED_1);
|
||||
msg.setPrefHeight(Region.USE_PREF_SIZE);
|
||||
msg.setMaxHeight(Region.USE_PREF_SIZE);
|
||||
StackPane.setAlignment(msg, Pos.TOP_RIGHT);
|
||||
StackPane.setMargin(msg, new Insets(10, 10, 0, 0));
|
||||
|
||||
msg.setOnClose(e -> {
|
||||
var out = Animations.slideOutUp(msg, Duration.millis(250));
|
||||
out.setOnFinished(f -> stackPane.getChildren().remove(msg));
|
||||
out.playFromStart();
|
||||
});
|
||||
|
||||
|
||||
var in = Animations.slideInDown(msg, Duration.millis(250));
|
||||
if (!stackPane.getChildren().contains(msg)) {
|
||||
stackPane.getChildren().add(msg);
|
||||
}
|
||||
in.playFromStart();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.jcnc.jnotepad.views.manager;
|
||||
|
||||
import atlantafx.base.controls.Notification;
|
||||
import atlantafx.base.theme.Styles;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
@ -227,15 +228,27 @@ public class TopMenuBarManager {
|
||||
bottomBox.setAlignment(Pos.BOTTOM_RIGHT);
|
||||
|
||||
leftBtn.setOnAction(event1 -> {
|
||||
|
||||
// 获取 RootManager 的实例
|
||||
RootManager rootManager = RootManager.getInstance();
|
||||
|
||||
// 创建一个新的 Notification
|
||||
Notification notification = new Notification();
|
||||
notification.setMessage("已成功复制软件信息!");
|
||||
|
||||
// 调用 RootManager 中的方法来显示 Notification
|
||||
rootManager.addNotificationToStackPane(rootManager.rootStackPane, notification);
|
||||
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
String info="软件名字:" + APP_NAME + "\t" + "版本:" + VERSION;
|
||||
String info = "软件名字:" + APP_NAME + "\t" + "版本:" + VERSION;
|
||||
content.putString(info);
|
||||
LogUtil.getLogger(this.getClass()).info("软件信息已经复制到剪贴板:" + info);
|
||||
clipboard.setContent(content);
|
||||
// 关闭当前的 Stage
|
||||
Stage currentStage = (Stage) leftBtn.getScene().getWindow();
|
||||
currentStage.close();
|
||||
|
||||
});
|
||||
|
||||
rightBtn.setOnAction(event1 -> {
|
||||
|
||||
@ -16,7 +16,6 @@ public class RootBorderPane extends AbstractBorderPane {
|
||||
private static final RootBorderPane INSTANCE = new RootBorderPane();
|
||||
|
||||
private RootBorderPane() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user