public DragLabel(String s) { this.setText(s); this.setOpaque(true); this.dragSource = DragSource.getDefaultDragSource(); this.dgListener = new DGListener(); this.dsListener = new DSListener(); // component, action, listener this.dragSource.createDefaultDragGestureRecognizer(this, this.dragAction, this.dgListener); }
public DragLabel(String s, int a) { if (a != DnDConstants.ACTION_NONE && a != DnDConstants.ACTION_COPY && a != DnDConstants.ACTION_MOVE && a != DnDConstants.ACTION_COPY_OR_MOVE && a != DnDConstants.ACTION_LINK) throw new IllegalArgumentException("action" + a); this.dragAction = a; this.setText(s); this.setOpaque(true); this.dragSource = DragSource.getDefaultDragSource(); this.dgListener = new DGListener(); this.dsListener = new DSListener(); // component, action, listener this.dragSource.createDefaultDragGestureRecognizer(this, this.dragAction, this.dgListener); }