增加设置页面
This commit is contained in:
parent
dc7ead7d8d
commit
442c7ebee6
@ -16,7 +16,6 @@ module org.jcnc.jnotepad {
|
||||
exports org.jcnc.jnotepad;
|
||||
exports org.jcnc.jnotepad.tool;
|
||||
exports org.jcnc.jnotepad.Interface;
|
||||
exports org.jcnc.jnotepad.controller.event.handler;
|
||||
exports org.jcnc.jnotepad.controller.manager;
|
||||
exports org.jcnc.jnotepad.view.manager;
|
||||
exports org.jcnc.jnotepad.constants;
|
||||
@ -27,4 +26,6 @@ module org.jcnc.jnotepad {
|
||||
opens org.jcnc.jnotepad.app.config;
|
||||
exports org.jcnc.jnotepad.ui.module;
|
||||
exports org.jcnc.jnotepad.ui.root.top.tools;
|
||||
exports org.jcnc.jnotepad.controller.event.handler.tool;
|
||||
exports org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.concurrent.Task;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
@ -0,0 +1,38 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler.tool;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
||||
import org.jcnc.jnotepad.constants.TextConstants;
|
||||
import org.jcnc.jnotepad.tool.UiUtil;
|
||||
import org.jcnc.jnotepad.ui.module.LineNumberTextArea;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.setStage.SetStage;
|
||||
import org.jcnc.jnotepad.view.manager.ViewManager;
|
||||
|
||||
|
||||
/**
|
||||
* 设置按钮事件的事件处理程序。
|
||||
* <p>
|
||||
* 当用户点击设置的时候,将打开设置窗口。
|
||||
*
|
||||
* @author 许轲
|
||||
*/
|
||||
public class SetBtn implements EventHandler<ActionEvent> {
|
||||
|
||||
/**
|
||||
* 打开设置窗口处理事件
|
||||
*
|
||||
* @param event 事件对象
|
||||
*/
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
SetStage.getInstance();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package org.jcnc.jnotepad.controller.manager;
|
||||
|
||||
import org.jcnc.jnotepad.Interface.ControllerAble;
|
||||
import org.jcnc.jnotepad.controller.event.handler.NewFile;
|
||||
import org.jcnc.jnotepad.controller.event.handler.OpenFile;
|
||||
import org.jcnc.jnotepad.controller.event.handler.menuBar.NewFile;
|
||||
import org.jcnc.jnotepad.controller.event.handler.menuBar.OpenFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@ -7,11 +7,13 @@ import javafx.stage.Stage;
|
||||
import org.jcnc.jnotepad.app.config.AppConfig;
|
||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
||||
import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
import org.jcnc.jnotepad.controller.event.handler.*;
|
||||
import org.jcnc.jnotepad.controller.event.handler.menuBar.*;
|
||||
import org.jcnc.jnotepad.controller.event.handler.tool.SetBtn;
|
||||
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.ui.root.top.tools.JNotepadToolBar;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
@ -110,6 +112,14 @@ public class JNotepadMenuBar extends MenuBar {
|
||||
private RadioMenuItem englishItem;
|
||||
private final Map<String, MenuItem> itemMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 工具栏
|
||||
*/
|
||||
JNotepadToolBar toolBar = JNotepadToolBar.getInstance();
|
||||
|
||||
// 获取工具栏中的setButton
|
||||
Button setButton = toolBar.getSetButton();
|
||||
|
||||
/**
|
||||
* 设置当前语言选中状态
|
||||
*
|
||||
@ -278,6 +288,7 @@ public class JNotepadMenuBar extends MenuBar {
|
||||
saveAsItem.setOnAction(new SaveAsFile());
|
||||
openConfigItem.setOnAction(new OpenConfig());
|
||||
renameItem.setOnAction(new RenameFile());
|
||||
setButton.setOnAction(new SetBtn());
|
||||
lineFeedItem.selectedProperty().addListener((observableValue, before, after) -> {
|
||||
// 1. 更新全局配置
|
||||
AppConfigController.getInstance().setAutoLineConfig(after);
|
||||
|
||||
@ -7,6 +7,9 @@ import javafx.scene.image.ImageView;
|
||||
|
||||
public class JNotepadToolBar extends ToolBar {
|
||||
private static final JNotepadToolBar INSTANCE = new JNotepadToolBar();
|
||||
|
||||
Button setButton = new Button();
|
||||
|
||||
private JNotepadToolBar() {
|
||||
// 创建工具栏上的按钮
|
||||
Image image = new Image("tools.png"); // 替换为你的图片文件路径
|
||||
@ -16,7 +19,6 @@ public class JNotepadToolBar extends ToolBar {
|
||||
imageView.setScaleX(2.5); // 设置水平缩放比例
|
||||
imageView.setScaleY(2.5); // 设置垂直缩放比例
|
||||
// 设置缩放比例
|
||||
Button setButton = new Button();
|
||||
setButton.setGraphic(imageView);
|
||||
|
||||
// 将按钮添加到工具栏
|
||||
@ -24,6 +26,10 @@ public class JNotepadToolBar extends ToolBar {
|
||||
|
||||
}
|
||||
|
||||
public Button getSetButton() {
|
||||
return setButton;
|
||||
}
|
||||
|
||||
public static JNotepadToolBar getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
package org.jcnc.jnotepad.ui.root.top.tools;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
public class ToolHBox extends HBox {
|
||||
private static final ToolHBox INSTANCE = new ToolHBox();
|
||||
|
||||
|
||||
private ToolHBox() {
|
||||
|
||||
HBox.setHgrow(JNotepadToolBar.getInstance(), Priority.ALWAYS); // 设置子节点水平拉伸
|
||||
@ -19,4 +19,7 @@ public class ToolHBox extends HBox {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
96
src/main/java/org/jcnc/jnotepad/ui/setStage/SetStage.java
Normal file
96
src/main/java/org/jcnc/jnotepad/ui/setStage/SetStage.java
Normal file
@ -0,0 +1,96 @@
|
||||
package org.jcnc.jnotepad.ui.setStage;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class SetStage {
|
||||
|
||||
private static final SetStage SET_STAGE = new SetStage();
|
||||
private StackPane contentDisplay; // Declare contentDisplay as a class member
|
||||
|
||||
public static SetStage getInstance() {
|
||||
return SET_STAGE;
|
||||
}
|
||||
|
||||
private SetStage() {
|
||||
openSetStage(new Stage());
|
||||
}
|
||||
|
||||
public void openSetStage(Stage setStage) {
|
||||
|
||||
contentDisplay = new StackPane(new Label("从左侧选择设置以显示内容"));
|
||||
|
||||
// 创建 TitledPane 组件
|
||||
TitledPane generalPane = new TitledPane("常规设置", createListView("常规设置项1", "常规设置项2"));
|
||||
TitledPane appearancePane = new TitledPane("外观设置", createListView("外观设置项1", "外观设置项2"));
|
||||
TitledPane securityPane = new TitledPane("安全设置", createListView("安全设置项1", "安全设置项2"));
|
||||
|
||||
generalPane.setOnMouseClicked(event -> {
|
||||
ListView<String> listView = (ListView<String>) generalPane.getContent();
|
||||
if (listView.getSelectionModel().getSelectedItem() != null) {
|
||||
contentDisplay.getChildren().setAll(new Label(listView.getSelectionModel().getSelectedItem() + " 的设置内容"));
|
||||
}
|
||||
});
|
||||
|
||||
appearancePane.setOnMouseClicked(event -> {
|
||||
ListView<String> listView = (ListView<String>) appearancePane.getContent();
|
||||
if (listView.getSelectionModel().getSelectedItem() != null) {
|
||||
contentDisplay.getChildren().setAll(new Label(listView.getSelectionModel().getSelectedItem() + " 的设置内容"));
|
||||
}
|
||||
});
|
||||
|
||||
securityPane.setOnMouseClicked(event -> {
|
||||
ListView<String> listView = (ListView<String>) securityPane.getContent();
|
||||
if (listView.getSelectionModel().getSelectedItem() != null) {
|
||||
contentDisplay.getChildren().setAll(new Label(listView.getSelectionModel().getSelectedItem() + " 的设置内容"));
|
||||
}
|
||||
});
|
||||
|
||||
// 创建一个 VBox 来容纳 TitledPanes
|
||||
VBox titledPaneContainer = new VBox(10);
|
||||
titledPaneContainer.getChildren().addAll(generalPane, appearancePane, securityPane);
|
||||
|
||||
// 创建一个占位符,用于显示右侧内容区域
|
||||
StackPane contentDisplay = new StackPane(new Label("从左侧选择设置以显示内容"));
|
||||
|
||||
// 设置 TitledPanes 的点击事件监听器
|
||||
generalPane.setOnMouseClicked(event -> contentDisplay.getChildren().setAll(new Label("常规设置内容")));
|
||||
appearancePane.setOnMouseClicked(event -> contentDisplay.getChildren().setAll(new Label("外观设置内容")));
|
||||
securityPane.setOnMouseClicked(event -> contentDisplay.getChildren().setAll(new Label("安全设置内容")));
|
||||
|
||||
// 创建一个水平分割面板来容纳整个布局
|
||||
SplitPane splitPane = new SplitPane(titledPaneContainer, contentDisplay);
|
||||
splitPane.setDividerPositions(0.3); // 设置分隔条位置
|
||||
|
||||
// 创建场景
|
||||
Scene scene = new Scene(splitPane, 800, 600);
|
||||
|
||||
// 设置场景并显示窗口
|
||||
setStage.setScene(scene);
|
||||
setStage.setTitle("设置窗口");
|
||||
setStage.show();
|
||||
}
|
||||
|
||||
private ListView<String> createListView(String... items) {
|
||||
ListView<String> listView = new ListView<>();
|
||||
listView.getItems().addAll(items);
|
||||
|
||||
listView.setOnMouseClicked(event -> {
|
||||
String selectedItem = listView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem != null) {
|
||||
contentDisplay.getChildren().setAll(new Label(selectedItem + " 的设置内容"));
|
||||
}
|
||||
});
|
||||
|
||||
return listView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user