Skip to content

Commit

Permalink
增加关闭标签快捷键
Browse files Browse the repository at this point in the history
  • Loading branch information
iamlinhui committed Dec 3, 2020
1 parent bbc5267 commit 1177d5b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/main/java/hi/chyl/json/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private JToolBar createToolBar() {
JToolBar toolbar = new JToolBar();
final JTextField textField = new JTextField();
textField.setMaximumSize(new Dimension(180, 25));
JButton btnAppTitle = new JButton("标题修改");
// JButton btnAppTitle = new JButton("标题修改");
JButton btnFormat = new JButton("格式化(F)");
JButton btnSort = new JButton("排序(G)");
JButton btnZip = new JButton("压缩(H)");
Expand All @@ -83,15 +83,14 @@ private JToolBar createToolBar() {
JButton btnNodeFind = new JButton("节点查找");
JButton btnNewTab = new JButton("新标签(N)");
JButton btnSelTabName = new JButton("标签名修改");
JButton btnCloseTab = new JButton("关闭标签");

btnAppTitle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(textField.getText());
getFrame().setTitle(textField.getText());
}
});
JButton btnCloseTab = new JButton("关闭标签(W)");

// btnAppTitle.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// getFrame().setTitle(textField.getText());
// }
// });
btnFormat.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Expand Down Expand Up @@ -214,7 +213,7 @@ public void actionPerformed(ActionEvent e) {
toolbar.add(btnTxtFind);
toolbar.addSeparator(new Dimension(30, 20));
toolbar.add(textField);
toolbar.add(btnAppTitle);
// toolbar.add(btnAppTitle);
toolbar.add(btnSelTabName);
return toolbar;
}
Expand Down Expand Up @@ -312,6 +311,19 @@ public void actionPerformed(ActionEvent evt) {
editMenu.add(menuItemZip);


JMenuItem menuItemClose = createMenuItem("menuItemClose", KeyEvent.VK_W);
menuItemClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
int selIndex = getTabIndex();
if (selIndex >= 0) {
tabDataModel.removeTab(selIndex);
}
}
});
editMenu.add(menuItemClose);


menuBar.add(editMenu);

toolMenu.setText(resourceMap.getString("toolMenu.text"));
Expand Down
1 change: 1 addition & 0 deletions src/main/java/hi/chyl/json/resources/MainView.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ menuItemClean.text = \u6E05\u7A7A
menuItemFormat.text = \u683C\u5F0F\u5316
menuItemSortFormat.text = \u6392\u5E8F
menuItemZip.text = \u538B\u7F29
menuItemClose.text = \u5173\u95ED\u6807\u7B7E
menuItemLayout.text = \u5E03\u5C40
menuItemNew.text = \u65B0\u6807\u7B7E
menuItemCode.text = \u6C49\u5B57\u53CD\u8F6C\u4E49
Expand Down

0 comments on commit 1177d5b

Please sign in to comment.