重构代码结构
This commit is contained in:
parent
76dc73da84
commit
571b8dd56a
@ -5,7 +5,6 @@ package org.jcnc.jnotepad;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public static final double SCREEN_WIDTH = 800; //宽度
|
public static final double SCREEN_WIDTH = 800; //宽度
|
||||||
public static final double SCREEN_LENGTH = 600; //高度
|
public static final double SCREEN_LENGTH = 600; //高度
|
||||||
public static final String APP_NAME = "JNotepad"; //名字
|
public static final String APP_NAME = "JNotepad"; //名字
|
||||||
|
|||||||
@ -16,14 +16,17 @@ import java.util.Objects;
|
|||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
import static org.jcnc.jnotepad.view.View.initItem;
|
||||||
|
import static org.jcnc.jnotepad.view.View.initTabPane;
|
||||||
|
|
||||||
public class LunchApp extends Application {
|
public class LunchApp extends Application {
|
||||||
private static final ExecutorService threadPool = Executors.newCachedThreadPool();
|
private static final ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||||
public static boolean isRelevance = true;
|
public static boolean isRelevance = true;
|
||||||
|
|
||||||
Controller controller = new Controller();
|
Controller controller = new Controller();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
View view=new View();
|
|
||||||
Pane root = new Pane();
|
Pane root = new Pane();
|
||||||
|
|
||||||
double width = Constants.SCREEN_WIDTH;
|
double width = Constants.SCREEN_WIDTH;
|
||||||
@ -44,8 +47,8 @@ public class LunchApp extends Application {
|
|||||||
viewManager.initScreen(scene);
|
viewManager.initScreen(scene);
|
||||||
|
|
||||||
// 初始化菜单项和标签栏
|
// 初始化菜单项和标签栏
|
||||||
view.initItem();
|
initItem();
|
||||||
View.initTabPane();
|
initTabPane();
|
||||||
|
|
||||||
if (isRelevance) {
|
if (isRelevance) {
|
||||||
// 使用线程池加载关联文件并创建文本区域
|
// 使用线程池加载关联文件并创建文本区域
|
||||||
|
|||||||
@ -127,7 +127,7 @@ public class Controller implements ControllerInterface {
|
|||||||
autoSave(textArea);
|
autoSave(textArea);
|
||||||
});
|
});
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
// 适当地处理异常
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@ public class LineFeedEventHandler implements EventHandler<ActionEvent> {
|
|||||||
public LineFeedEventHandler(TextArea textArea) {
|
public LineFeedEventHandler(TextArea textArea) {
|
||||||
this.textArea = textArea;
|
this.textArea = textArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
String text = textArea.getText();
|
String text = textArea.getText();
|
||||||
|
|||||||
@ -9,11 +9,6 @@ import org.jcnc.jnotepad.ViewManager;
|
|||||||
import static org.jcnc.jnotepad.ViewManager.tabPane;
|
import static org.jcnc.jnotepad.ViewManager.tabPane;
|
||||||
|
|
||||||
public class NewFileEventHandler implements EventHandler<ActionEvent> {
|
public class NewFileEventHandler implements EventHandler<ActionEvent> {
|
||||||
|
|
||||||
|
|
||||||
public NewFileEventHandler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
Controller controller = new Controller();
|
Controller controller = new Controller();
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package org.jcnc.jnotepad.tool;
|
package org.jcnc.jnotepad.tool;
|
||||||
|
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user