static JTable sexyTableWithoutDrag() {
final JTable table = tableWithToolTips();
tablePopupMenu(table, sexyTableWithoutDrag_popupMenuMaker(table));
// Disable Ctrl+PageUp and Ctrl+PageDown
table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK), "none");
//table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_MASK), "none");
/*table.registerKeyboardAction(
null,
KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
);*/
table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK), "none");
table.getInputMap(JComponent.WHEN_FOCUSED)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK), "none");
table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK), "none");
table.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK), "none");
((InputMap) UIManager.get("Table.ancestorInputMap")).put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK), "none");
ret table;
}
static VF2<JPopupMenu, Int> sexyTableWithoutDrag_popupMenuMaker(JTable t) {
final WeakReference<JTable> ref = weakRef(t);
ret voidfunc(JPopupMenu menu, int row) {
final JTable table = ref!;
final S item = first(getTableLine(table, row));
MouseEvent e = tablePopupMenu_mouseEvent!;
final int col = table.columnAtPoint(e.getPoint());
final O value = table.getModel().getValueAt(row, col);
//print("Cell type: " + getClassName(value));
if (value instanceof ImageIcon) {
addMenuItem(menu, "Copy image to clipboard", r {
copyImageToClipboard(((ImageIcon) value).getImage());
});
} else {
final S text = str(value);
addMenuItem(menu, "Copy text to clipboard", r {
copyTextToClipboard(text);
print("Copied text to clipboard: " + quote(text));
});
}
addMenuItem(menu, "Set row height...", r {
final JTextField tf = jTextField(table.getRowHeight());
showTitledForm("Set row height",
"Pixels", tf, r {
table.setRowHeight(parseInt(trim(tf.getText())))
});
});
};
}Began life as a copy of #1004471
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1009201 |
| Snippet name: | sexyTableWithoutDrag - JTable with latest fancy stuff, but without drag-enable (bad for double clicks) |
| Eternal ID of this version: | #1009201/7 |
| Text MD5: | f9890adb2b728d2cb1bbc9244827be87 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-07-07 17:08:10 |
| Source code size: | 2470 bytes / 58 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1173 / 1141 |
| Version history: | 6 change(s) |
| Referenced in: | [show references] |