Uses 3874K of libraries. Click here for Pure Java version (4994L/35K/128K).
1 | !7 |
2 | |
3 | p-substance { |
4 | final JTable table = showTable(ll( |
5 | litorderedmap("Hello" := "World", "How" := "Good"), |
6 | litorderedmap("Hello" := "Boys", "How" := "Whatever"))); |
7 | |
8 | TransferHandler th = new TransferHandler { |
9 | @Override |
10 | public int getSourceActions(JComponent c) { |
11 | return COPY; |
12 | } |
13 | |
14 | @Override |
15 | protected Transferable createTransferable(JComponent c) { |
16 | print("Row/Column: " + table.getSelectedRow() + " / " + table.getSelectedColumn()); |
17 | O o = selectedTableCell(table); |
18 | print("Value: " + o); |
19 | return new StringSelection(str(o)); |
20 | } |
21 | }; |
22 | |
23 | tableEnableDrag(table, th); |
24 | } |
25 | |
26 | svoid tableEnableDrag(final JTable table, TransferHandler th) { |
27 | table.setDragEnabled(true); |
28 | table.setTransferHandler(th); |
29 | table.addMouseListener(new MouseAdapter { |
30 | @Override |
31 | public void mousePressed(MouseEvent e) { |
32 | table.getTransferHandler().exportAsDrag(table, e, TransferHandler.COPY); |
33 | } |
34 | }); |
35 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1007215 |
Snippet name: | Try making JTable a drag source [WORKS] |
Eternal ID of this version: | #1007215/9 |
Text MD5: | 2e67b0759cba0394214dc918f47cf816 |
Transpilation MD5: | a4efa152833d177562a1fc586ede27dd |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-12 12:33:26 |
Source code size: | 984 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 471 / 554 |
Version history: | 8 change(s) |
Referenced in: | [show references] |