fixed menu

This commit is contained in:
Radek Davidek 2026-01-20 19:58:56 +01:00
parent e72f9d602f
commit 571cf2cb68
2 changed files with 28 additions and 5 deletions

View File

@ -778,6 +778,8 @@ public class MainWindow extends JFrame {
@Override
public void mousePressed(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) {
// Close the menu first to release focus
MenuSelectionManager.defaultManager().clearSelectedPath();
showSettingsDialog();
}
}

View File

@ -239,6 +239,14 @@ public class SettingsDialog extends JDialog {
btns.add(ok);
btns.add(cancel);
add(btns, BorderLayout.SOUTH);
// Ensure dialog has focus when opened
addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowOpened(java.awt.event.WindowEvent e) {
categoryList.requestFocusInWindow();
}
});
}
private JPanel buildAppearancePanel() {
@ -640,6 +648,7 @@ public class SettingsDialog extends JDialog {
gbc.gridx = 1;
gbc.weightx = 0;
gbc.gridwidth = 2; // Span across the rest
JButton browseBtn = new JButton("Browse...");
browseBtn.addActionListener(e -> {
JFileChooser chooser = new JFileChooser();
@ -666,8 +675,18 @@ public class SettingsDialog extends JDialog {
gbc.gridx = 0;
gbc.gridy++;
gbc.gridwidth = 1;
gbc.weightx = 0.5;
gbc.weightx = 0;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
JPanel actionBtnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JButton exportBtn = new JButton("Export");
JButton importBtn = new JButton("Import");
Dimension actionSize = new Dimension(100, exportBtn.getPreferredSize().height);
exportBtn.setPreferredSize(actionSize);
importBtn.setPreferredSize(actionSize);
exportBtn.addActionListener(e -> {
String path = pathField.getText();
if (path.isEmpty()) {
@ -683,10 +702,7 @@ public class SettingsDialog extends JDialog {
JOptionPane.showMessageDialog(this, "Error exporting configuration: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
});
p.add(exportBtn, gbc);
gbc.gridx = 1;
JButton importBtn = new JButton("Import");
importBtn.addActionListener(e -> {
String path = pathField.getText();
if (path.isEmpty()) {
@ -714,13 +730,18 @@ public class SettingsDialog extends JDialog {
}
}
});
p.add(importBtn, gbc);
actionBtnPanel.add(exportBtn);
actionBtnPanel.add(Box.createHorizontalStrut(10));
actionBtnPanel.add(importBtn);
p.add(actionBtnPanel, gbc);
// Add spacer
gbc.gridx = 0;
gbc.gridy++;
gbc.gridwidth = 3;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
p.add(new JPanel(), gbc);
return p;