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

17
LINES

< > BotCompany Repo | #1009348 // listEnableDrag

JavaX fragment (include)

1  
import java.awt.datatransfer.Transferable;
2  
3  
static void listEnableDrag(final JList list, TransferHandler th) {
4  
  if (list.getDragEnabled()) {
5  
    print("List drag already enabled");
6  
    ret;
7  
  }
8  
  list.setDragEnabled(true);
9  
  list.setTransferHandler(th);
10  
  list.addMouseListener(new MouseAdapter {
11  
    @Override
12  
    public void mousePressed(MouseEvent e) {
13  
      if (e.getButton() == 1 && e.getClickCount() == 1)
14  
        list.getTransferHandler().exportAsDrag(list, e, TransferHandler.COPY);
15  
    }
16  
  });
17  
}

Author comment

Began life as a copy of #1007217

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: #1009348
Snippet name: listEnableDrag
Eternal ID of this version: #1009348/4
Text MD5: 415d495c835fca71138aa63cd027599a
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-24 12:28:50
Source code size: 521 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 436 / 477
Version history: 3 change(s)
Referenced in: [show references]