快捷键调整
parent
b7ea976fa8
commit
7afb82fdf2
|
@ -5,6 +5,9 @@ start7410
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
start7410
|
||||
2+
|
||||
有关成长的优美散文:在体验中成长生活丰富多彩,探索它也是很有趣的。
|
||||
|
@ -13,6 +16,9 @@ start7410
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
start7410
|
||||
3+
|
||||
如今社会步入小康,百姓们再也不用像以前一样担忧粮食了。每当到吃饭时间,父母总是做好饭喊我吃,我就只要乖乖吃饭就可以了。
|
||||
|
@ -20,6 +26,9 @@ start7410
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
start7410
|
||||
4+
|
||||
买菜。
|
||||
|
@ -28,3 +37,6 @@ start7410
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: top.dreamcenter.note.Main
|
||||
|
|
@ -72,6 +72,11 @@ public class Main {
|
|||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
dateList.set(curPage[0], date.getText());
|
||||
|
||||
switch (e.getKeyCode()) {
|
||||
case KeyEvent.VK_ENTER -> textArea.requestFocus();
|
||||
case KeyEvent.VK_ESCAPE -> exitSystem(jf, contentlist, dateList);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -100,22 +105,15 @@ public class Main {
|
|||
date.setText(dateList.get(curPage[0]));
|
||||
}
|
||||
}
|
||||
case KeyEvent.VK_F7 -> { // 保存
|
||||
saveData(contentlist, dateList);
|
||||
}
|
||||
case KeyEvent.VK_F7 -> saveData(contentlist, dateList);
|
||||
case KeyEvent.VK_ESCAPE -> exitSystem(jf, contentlist, dateList);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
jf.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
int confirm = JOptionPane.showConfirmDialog(jf, "是否保存并退出?", "保存退出", JOptionPane.YES_NO_CANCEL_OPTION);
|
||||
if (confirm == JOptionPane.YES_OPTION) {
|
||||
saveData(contentlist, dateList);
|
||||
System.exit(0);
|
||||
} else if (confirm == JOptionPane.NO_OPTION) {
|
||||
System.exit(0);
|
||||
}
|
||||
exitSystem(jf, contentlist, dateList);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -129,6 +127,16 @@ public class Main {
|
|||
jf.setVisible(true);
|
||||
}
|
||||
|
||||
private static void exitSystem(JFrame jf, LinkedList<String> contentList, LinkedList<String> dateList) {
|
||||
int confirm = JOptionPane.showConfirmDialog(jf, "是否保存并退出?", "保存退出", JOptionPane.YES_NO_CANCEL_OPTION);
|
||||
if (confirm == JOptionPane.YES_OPTION) {
|
||||
saveData(contentList, dateList);
|
||||
System.exit(0);
|
||||
} else if (confirm == JOptionPane.NO_OPTION) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initList(List<String> contentList, List<String> dateList) {
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
|
@ -179,6 +187,7 @@ public class Main {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static void saveData(List<String> contentList, List<String> dateList){
|
||||
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)))) {
|
||||
for (int i = 0; i < TOTAL_PAGE; i++) {
|
||||
|
@ -200,7 +209,6 @@ public class Main {
|
|||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "保存失败:" + e.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue