重构代码
This commit is contained in:
parent
15c6660a5a
commit
4f0b51c735
@ -13,7 +13,7 @@ import org.jcnc.jnotepad.view.View;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.jcnc.jnotepad.viewManager.tabPane;
|
||||
import static org.jcnc.jnotepad.ViewManager.tabPane;
|
||||
import static org.jcnc.jnotepad.controller.Controller.updateStatusLabel;
|
||||
|
||||
public class MainApp extends Application {
|
||||
@ -37,7 +37,7 @@ public class MainApp extends Application {
|
||||
primaryStage.getIcons().add(new Image((Objects.requireNonNull(getClass().getResource(icon))).toString()));
|
||||
primaryStage.show();
|
||||
|
||||
viewManager viewManager = org.jcnc.jnotepad.viewManager.getInstance(scene);
|
||||
ViewManager viewManager = ViewManager.getInstance(scene);
|
||||
|
||||
viewManager.initScreen(scene);
|
||||
|
||||
@ -52,7 +52,7 @@ public class MainApp extends Application {
|
||||
TextArea textArea = Controller.openAssociatedFileAndCreateTextArea(rawParameters);
|
||||
if (isRelevance) {
|
||||
// 创建新标签页并添加到标签栏
|
||||
Tab tab = new Tab("新建文件 " + ++viewManager.tabIndex);
|
||||
Tab tab = new Tab("新建文件 " + ++ViewManager.tabIndex);
|
||||
tab.setContent(textArea);
|
||||
tabPane.getTabs().add(tab);
|
||||
tabPane.getSelectionModel().select(tab);
|
||||
|
||||
@ -9,7 +9,7 @@ import javafx.scene.layout.HBox;
|
||||
/**
|
||||
* 该类管理记事本应用程序的视图组件。
|
||||
*/
|
||||
public class viewManager {
|
||||
public class ViewManager {
|
||||
|
||||
public static Label enCodingLabel; // 显示文本编码
|
||||
|
||||
@ -29,7 +29,7 @@ public class viewManager {
|
||||
// 状态栏
|
||||
public static Label statusLabel;
|
||||
|
||||
private static viewManager instance = null;
|
||||
private static ViewManager instance = null;
|
||||
|
||||
/**
|
||||
* 获取ViewManager的实例。如果实例不存在,则创建一个新实例。
|
||||
@ -37,9 +37,9 @@ public class viewManager {
|
||||
* @param scene 与视图相关联的JavaFX场景。
|
||||
* @return ViewManager的实例。
|
||||
*/
|
||||
public static viewManager getInstance(Scene scene) {
|
||||
public static ViewManager getInstance(Scene scene) {
|
||||
if (instance == null) {
|
||||
instance = new viewManager(scene);
|
||||
instance = new ViewManager(scene);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class viewManager {
|
||||
*
|
||||
* @param scene 与视图相关联的JavaFX场景。
|
||||
*/
|
||||
private viewManager(Scene scene) {
|
||||
private ViewManager(Scene scene) {
|
||||
root = new BorderPane();
|
||||
scene.setRoot(root);
|
||||
}
|
||||
@ -11,7 +11,7 @@ import org.jcnc.jnotepad.MainApp;
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jcnc.jnotepad.viewManager.*;
|
||||
import static org.jcnc.jnotepad.ViewManager.*;
|
||||
|
||||
/**
|
||||
* 控制器类负责处理与用户界面的交互,并实现相关事件处理逻辑。
|
||||
|
||||
@ -3,7 +3,7 @@ package org.jcnc.jnotepad.view;
|
||||
import javafx.scene.control.TextArea;
|
||||
import org.jcnc.jnotepad.controller.Controller;
|
||||
|
||||
import static org.jcnc.jnotepad.viewManager.*;
|
||||
import static org.jcnc.jnotepad.ViewManager.*;
|
||||
import static org.jcnc.jnotepad.controller.Controller.upDateEncodingLabel;
|
||||
import static org.jcnc.jnotepad.controller.Controller.updateStatusLabel;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user