added context menu for adding entries in empty space of the entry table
This commit is contained in:
parent
de90564c5b
commit
6ad095d8cf
@ -396,6 +396,36 @@ public class KeepassApp extends JFrame {
|
|||||||
});
|
});
|
||||||
JScrollPane tableScrollPane = new JScrollPane(entryTable);
|
JScrollPane tableScrollPane = new JScrollPane(entryTable);
|
||||||
|
|
||||||
|
// Add popup menu for empty space in table scrollpane
|
||||||
|
tableScrollPane.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
showEmptySpacePopupMenu(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
showEmptySpacePopupMenu(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showEmptySpacePopupMenu(MouseEvent e) {
|
||||||
|
if (!e.isPopupTrigger()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check if click is actually in empty space (not on a row)
|
||||||
|
int row = entryTable.rowAtPoint(e.getPoint());
|
||||||
|
if (row >= 0) {
|
||||||
|
return; // Click is on a row, let the table's mouse listener handle it
|
||||||
|
}
|
||||||
|
|
||||||
|
JPopupMenu popup = new JPopupMenu();
|
||||||
|
JMenuItem addPop = new JMenuItem("Add Entry");
|
||||||
|
addPop.addActionListener(al -> addEntry());
|
||||||
|
popup.add(addPop);
|
||||||
|
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Right side: Table and Notes
|
// Right side: Table and Notes
|
||||||
rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tableScrollPane, notesScrollPane);
|
rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tableScrollPane, notesScrollPane);
|
||||||
int rightDivider = prefs.getInt(PREF_RIGHT_DIVIDER, 250);
|
int rightDivider = prefs.getInt(PREF_RIGHT_DIVIDER, 250);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user