properties dialog closable with esc

This commit is contained in:
Radek Davidek 2026-02-03 15:42:05 +01:00
parent 9e02b23f49
commit 7ec4ca8946
2 changed files with 6 additions and 1 deletions

View File

@ -15,7 +15,7 @@ import java.io.InputStreamReader;
*/ */
public class MainApp { public class MainApp {
public static final String APP_VERSION = "1.1.0"; public static final String APP_VERSION = "1.1.1";
public enum OS { public enum OS {
WINDOWS, LINUX, MACOS, UNKNOWN WINDOWS, LINUX, MACOS, UNKNOWN

View File

@ -6,6 +6,7 @@ import cz.kamma.kfmanager.model.FileItem;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.*; import java.nio.file.*;
@ -64,6 +65,10 @@ public class PropertiesDialog extends JDialog {
buttonPanel.add(okButton); buttonPanel.add(okButton);
buttonPanel.add(cancelButton); buttonPanel.add(cancelButton);
add(buttonPanel, BorderLayout.SOUTH); add(buttonPanel, BorderLayout.SOUTH);
getRootPane().registerKeyboardAction(e -> dispose(),
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
} }
private JPanel buildPropertiesPanel() { private JPanel buildPropertiesPanel() {