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

24
LINES

< > BotCompany Repo | #1007216 // Try making JLabel a drag source [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 3874K of libraries. Compilation Failed (3183L/22K).

1  
!7
2  
3  
import java.awt.datatransfer.*;
4  
import java.awt.dnd.*;
5  
6  
p-substance {
7  
  final JLabel label = jCenteredLabel(randomID(20));
8  
  showFrame(label);
9  
  
10  
  TransferHandler th = new TransferHandler {
11  
    @Override
12  
    public int getSourceActions(JComponent c) {
13  
        return COPY;
14  
    }
15  
16  
    @Override
17  
    protected Transferable createTransferable(JComponent c) {
18  
      return new StringSelection(getText(label));
19  
    }
20  
  };
21  
  
22  
  label.setDragEnabled(true);
23  
  label.setTransferHandler(th);
24  
}

Author comment

Began life as a copy of #1007215

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: #1007216
Snippet name: Try making JLabel a drag source [dev.]
Eternal ID of this version: #1007216/10
Text MD5: 81af08eba2812bc3f16f0504227c1807
Transpilation MD5: d921369563c1d31f3203d092b1c8abde
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:21:36
Source code size: 511 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 467 / 562
Version history: 9 change(s)
Referenced in: [show references]