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).

!7

import java.awt.datatransfer.*;
import java.awt.dnd.*;

p-substance {
  final JLabel label = jCenteredLabel(randomID(20));
  showFrame(label);
  
  TransferHandler th = new TransferHandler {
    @Override
    public int getSourceActions(JComponent c) {
        return COPY;
    }

    @Override
    protected Transferable createTransferable(JComponent c) {
      return new StringSelection(getText(label));
    }
  };
  
  label.setDragEnabled(true);
  label.setTransferHandler(th);
}

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: 465 / 560
Version history: 9 change(s)
Referenced in: [show references]