Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data


< > BotCompany Repo | #1009201 - sexyTableWithoutDrag - JTable with latest fancy stuff, but without drag-enable (bad for double clicks)

JavaX fragment (include)

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");
    KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK),
    .put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK), "none");
    .put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK), "none");
    .put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK), "none");
    .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 {
        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 {

Author comment

Began life as a copy of #1004471

download  show line numbers  debug dex   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz

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: 361 / 335
Version history: 6 change(s)
Referenced in: [show references]

Formerly at &