Drag and Drop in custom components..

hello friends,
I am trying to devlop a schedule component. on part of this i trying to develop a functionality where the user can reschedure the appointment by drag and drop.  the dragdrop event in the container component is not triggered when ther user drag the appointment and drop it in the another container. can any one help me on this please. i have given below my source codes.
Testbox.as
package layouts.DayViewControl.containers
    import mx.core.Container;
    public class TestBox extends Container
        private var __timeAndXYCoOrdArray:Array;
        private var __xyDiff:int=0;
        public function TestBox()
            super();
            __timeAndXYCoOrdArray=new Array();
        protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
            super.updateDisplayList(unscaledWidth,unscaledHeight);
            var totalSlots:int=24*2;
            var __lineThickness:int=1;
            var __lineAlpha:int=0.2;
            var boxHeight:uint=unscaledHeight/totalSlots;
            graphics.clear();
            var xPos:int=0;
            var ypos:int=0;
            graphics.lineStyle(2,0x000000,0.5);
            graphics.drawRect(0,0,unscaledWidth,unscaledHeight);
            var __boxHeight:int=unscaledHeight/totalSlots;
            var __minusCount:int=1;
            for(var i:int=0;i<totalSlots;i++){
                var timeStr:String="";
                if(i%2 == 0){
                    __lineThickness=2;
                    graphics.lineStyle(__lineThickness,0x000000,0.4);               
                }else{
                    __lineThickness=1;
                    graphics.lineStyle(__lineThickness,0x000000,0.2);   
                graphics.moveTo(xPos,ypos);
                var tempYpos:int=ypos;
                if(__xyDiff == 0){
                    __xyDiff=ypos-xPos;
                graphics.lineTo(xPos+unscaledWidth,tempYpos);
                ypos+=boxHeight;
                var newYPos:int=0;
                if(i == 0){
                    timeStr="00:00";
                }else if(i%2 != 0){
                    if(i<=9){
                        timeStr="0"+(i-__minusCount).toString()+":30";
                    }else{
                        timeStr=(i-__minusCount).toString()+":30";                       
                    newYPos=ypos-__xyDiff;
                }else if(i%2 == 0){
                    if(i<=9){
                        timeStr="0"+(i-__minusCount).toString()+":00";
                    }else{
                        timeStr=(i-__minusCount).toString()+":00";                       
                    __minusCount+=1;
                    newYPos=ypos-__xyDiff;
                __timeAndXYCoOrdArray.push({XPos:xPos,YPos:newYPos,Time:timeStr});
        public function getXFromtime(inputTime:String):int{
            var returnVal:int=0;
            if(inputTime && inputTime != ""){
                for (var j:int=0;j<__timeAndXYCoOrdArray.length;j++){
                    if(__timeAndXYCoOrdArray[j].Time.toString() == inputTime){
                        returnVal=parseInt(__timeAndXYCoOrdArray[j].XPos)
                        break;
            return returnVal;
        public function getYFromtime(inputTime:String):int{
            var returnVal:int=0;
            if(inputTime && inputTime != ""){
                for (var j:int=0;j<__timeAndXYCoOrdArray.length;j++){
                    if(__timeAndXYCoOrdArray[j].Time.toString() == inputTime){
                        returnVal=parseInt(__timeAndXYCoOrdArray[j].YPos)
                        break;
            return returnVal;
        public function getTimeDifference():int{
            return __xyDiff;
TimeDividerLines.as
package layouts.DayViewControl
    import flash.events.MouseEvent;
    import flash.utils.Dictionary;
    import layouts.DayViewControl.containers.TestBox;
    import mx.collections.ArrayCollection;
    import mx.core.DragSource;
    import mx.core.EventPriority;
    import mx.core.UIComponent;
    import mx.events.DragEvent;
    import mx.managers.DragManager;
    public class TimeDividerLines extends TestBox
        private var __linesPerHour:int=4;
        private var __currentDate:Date;
        private var __timeAndXYCoOrdArray:Array;
        private var __dataComponentArry:Array;
        private var __totalAppointment:int=5;
        private var __xyDiff:int=0;
        private var __apptDataInfoArry:Array;
        private var __dataProviderChanged:Boolean=false;
        private var __reArrangeDataArrayCol:ArrayCollection;
        private var __sortedArrayCollection:ArrayCollection;
        private var __dragDropEnabled:Boolean=false;
        public function TimeDividerLines()
            super();
            //__timeAndXYCoOrdArray=new Array();
            __dataComponentArry=new Array();
            __apptDataInfoArry=new Array();
            __sortedArrayCollection=new ArrayCollection();   
        public function set dragDropEnabled(inputVal:Boolean):void{
            if(inputVal){
                //set youself for drag and drop event
                this.addEventListener(DragEvent.DRAG_ENTER,dragEnterEventHandler,false,EventPriority.DEFA ULT_HANDLER);
                this.addEventListener(DragEvent.DRAG_OVER,dragOverEventHandler,false,EventPriority.DEFAUL T_HANDLER);
                this.addEventListener(DragEvent.DRAG_DROP,dragDropEventHandler,false,EventPriority.DEFAUL T_HANDLER);
                this.addEventListener(DragEvent.DRAG_COMPLETE,dropCompleteHandler);               
            }else{
                this.removeEventListener(DragEvent.DRAG_ENTER,dragEnterEventHandler,false);
                this.removeEventListener(DragEvent.DRAG_OVER,dragOverEventHandler,false);
                this.removeEventListener(DragEvent.DRAG_DROP,dragDropEventHandler,false);               
            __dragDropEnabled=inputVal;
        private function dropCompleteHandler(event:DragEvent):void{
            trace("inside drop complete handler");
        private function dragEnterEventHandler(event:DragEvent):void{
            if(event.dragSource.hasFormat("Appointment")){
                var dropTarget:UIComponent=UIComponent(event.currentTarget);
                DragManager.acceptDragDrop(dropTarget);           
                DragManager.showFeedback(event.ctrlKey ? DragManager.COPY : DragManager.MOVE);   
                return;
            DragManager.showFeedback(DragManager.NONE);
        private function dragOverEventHandler(event:DragEvent):void{
            /* if(event.dragSource.hasFormat("Appointment")){
                if(event.ctrlKey){
                    DragManager.showFeedback(DragManager.COPY);
                    return
                }else{
                    DragManager.showFeedback(DragManager.MOVE);
                    return
            DragManager.showFeedback(DragManager.NONE); */
        private function dragDropEventHandler(event:DragEvent):void{
            //We need to do two things here. you need to add the dropped data to the data provider list.
            //and need need to update this entry to DB
             /* if(event.dragSource.hasFormat("Appointment")){
                 var draggedbox:AppointmentDisplayBox=event.dragSource.dataForFormat("Appointment") as AppointmentDisplayBox;
                 var dropBox:TimeDividerLines=event.currentTarget as TimeDividerLines;
                 //create a new copy
                 var newBox:AppointmentDisplayBox=new AppointmentDisplayBox();
                 newBox=draggedbox;
                 newBox.x=dropBox.mouseX;
                 newBox.y=dropBox.mouseY;
                 this.addChild(newBox);
             trace("11111111111111111111111111111111111111111")
        private function mouseDownHandler(event:MouseEvent):void{
            var draginit:AppointmentDisplayBox=AppointmentDisplayBox(event.currentTarget);
            var ds:DragSource=new DragSource();
            ds.addData(draginit,"Appointment");
            DragManager.doDrag(draginit,ds,event);
        override protected function createChildren():void{
            super.createChildren();
        override protected function commitProperties():void{
             if(__dataProviderChanged){
                 __dataComponentArry=new Array();
                for (var k:int=0;k<__apptDataInfoArry.length;k++){
                    var tempDispBox:AppointmentDisplayBox=new AppointmentDisplayBox();
                    tempDispBox.currentDate=this.currentDate;
                    tempDispBox.startTime=__apptDataInfoArry[k].StartTime.toString();
                    tempDispBox.endTime=__apptDataInfoArry[k].EndTime.toString();
                    tempDispBox.apptDataXml=__apptDataInfoArry[k].Data as XML;       
                    tempDispBox.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);           
                    this.addChild(tempDispBox);
                    __dataComponentArry.push(tempDispBox);
                __dataProviderChanged=false;
        private function sortTheCollectionValues(__inputArrayCol:ArrayCollection):ArrayCollection{
            var returnArrayCollection:ArrayCollection=new ArrayCollection();
            var tempArray:Array=new Array();
            for(var i:int=0;i<__inputArrayCol.length;i++){
                tempArray.push({Length:(__inputArrayCol[i] as Array).length,Index:i});
            tempArray.sortOn("Length",Array.DESCENDING|Array.NUMERIC);
            for(var j:int=0;j<tempArray.length;j++){
                returnArrayCollection.addItem(__inputArrayCol[tempArray[j].Index]);
            return returnArrayCollection;
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
            super.updateDisplayList(unscaledWidth,unscaledHeight);
            if(__dataComponentArry.length > 0){
                __sortedArrayCollection=new ArrayCollection();
                sortArray(__dataComponentArry);
            if(__sortedArrayCollection.length > 0 ){
                //you need to sort the arraycollection based on the length first to draw the highest no. child array first
                __sortedArrayCollection=sortTheCollectionValues(__sortedArrayCollection);
                var appGap:int=2;
                var endGap:int=10;
                //var drawnApptObj:Array=new Array();
                var existingChildArray:Array=new Array();   
                var drawnApptObj:Dictionary=new Dictionary();
                for(var l:int=0;l<__sortedArrayCollection.length;l++){
                    var apptWidth:int=0;
                    var innerArry:Array=__sortedArrayCollection[l] as Array;
                    existingChildArray=new Array();
                    //you need to recalculate the width
                    //for the first iteration you need to sort by height
                    //if(l == 0){
                    //    innerArry.sortOn("apptHeight",Array.NUMERIC|Array.DESCENDING);
                    //}else{
                        innerArry.sortOn(["isChild","apptHeight"],Array.NUMERIC|Array.DESCENDING);   
                    //innerArry.sortOn("apptHeight",Array.NUMERIC|Array.DESCENDING);
                    //first we need to find out any intersection appointment is there
                    var count:int=0;
                     for each(var tempApptDispBox:AppointmentDisplayBox in innerArry){
                        if(drawnApptObj[tempApptDispBox] == tempApptDispBox){
                            if(apptWidth < tempApptDispBox.width){
                                apptWidth=tempApptDispBox.width;
                                existingChildArray.push({index:count,object:tempApptDispBox});
                        count++;
                    if(apptWidth == 0){
                        apptWidth=(unscaledWidth - (endGap + (appGap*innerArry.length)))/innerArry.length;
                    //now you need to layout the childrens
                    var canDraw:Boolean=false;
                    var ismatch:Boolean=false;
                    for (var childCnt:int=0;childCnt < innerArry.length;childCnt++){
                         var tempDispBox:AppointmentDisplayBox=innerArry[childCnt] as AppointmentDisplayBox;
                         for (var i:int=0;i<existingChildArray.length;i++){
                             if(existingChildArray[i].index == childCnt){
                                 ismatch=true;
                                 break;
                        if(childCnt == 0 && !ismatch){
                            tempDispBox.x=this.getXFromtime(tempDispBox.startTime.toString())+2;
                            canDraw=true;
                        }else if(existingChildArray.indexOf(childCnt) > -1 && childCnt != 0){
                            //tempDispBox.x=(existingChildArray[childCnt] as AppointmentDisplayBox).x+apptWidth+appGap;
                            canDraw=false;
                        }else if(childCnt != 0 && !ismatch){
                            tempDispBox.x=((existingChildArray[childCnt-1].object) as AppointmentDisplayBox).x+apptWidth+appGap;
                            canDraw=true;
                        if(canDraw){
                            tempDispBox.y=this.getYFromtime(tempDispBox.startTime.toString());   
                            tempDispBox.width=apptWidth;
                            tempDispBox.height=tempDispBox.apptHeight-2;
                            if(tempDispBox.isChild){
                                drawnApptObj[tempDispBox]=tempDispBox;
                            existingChildArray.push({index:childCnt,object:tempDispBox});
                        canDraw=false;
                        ismatch=false;
            //first we need to sort the component array based on the height property to position the biggest appointment first
        private function sortArray(tempArry:Array):void{
            //var tempArry:Array=arrayClone(__datacompArray);
             for(var i:int=0;i<tempArry.length;i++){
                 var tempDispBox:AppointmentDisplayBox=tempArry[i] as AppointmentDisplayBox;
                var start:int=this.getYFromtime(tempDispBox.startTime.toString());
                var end:int=this.getYFromtime(tempDispBox.endTime.toString());
                tempDispBox.apptHeight=end-start;
            var indexArray:Array=new Array();
            var canContinue:Boolean=false;
            var loopArray:Array=new Array();
            loopArray=tempArry.concat(); // this will copy the array to loopArray
            var copyArry:Array=new Array();
            var k:int=0;
            while(k<loopArray.length){
                loopArray.sortOn("apptHeight",Array.NUMERIC|Array.DESCENDING);
                if(indexArray.length > 0){
                    if(indexArray.indexOf(k) >= 0){
                        canContinue=false;
                    }else{
                        canContinue=true;
                }else{
                    canContinue=true;
                if(canContinue){
                    var newArry:Array=new Array();
                    //newArry.push(tempArry[k]);                   
                    for (var innerCnt:int=0;innerCnt<loopArray.length;innerCnt++){
                        var locCanContinue:Boolean=false;
                        if(indexArray.length > 0){
                            if(indexArray.indexOf(innerCnt) >= 0){
                                locCanContinue=false;
                            }else{
                                locCanContinue=true;
                        }else{
                            locCanContinue=true;
                        if(locCanContinue && k != innerCnt){
                            var outerstartTime:Number=parseFloat(loopArray[k].startTime.toString().replace(":","."));
                            var outerendtime:Number=parseFloat(loopArray[k].endTime.toString().replace(":","."));
                            var innerStartTime:Number=parseFloat(loopArray[innerCnt].startTime.toString().replace(":","." ));
                            var innerEndtime:Number=parseFloat(loopArray[innerCnt].endTime.toString().replace(":","."));
                            if(outerstartTime == innerStartTime && outerendtime == innerEndtime){
                                //newArry.push(tempArry.splice(innerCnt,1));
                                newArry.push(loopArray[innerCnt]);
                                indexArray.push(innerCnt);
                            }else if(outerstartTime == innerStartTime && outerendtime > innerEndtime){
                                //newArry.push(tempArry.splice(innerCnt,1));
                                newArry.push(loopArray[innerCnt]);
                                indexArray.push(innerCnt);
                            }else if(outerstartTime  < innerStartTime && outerendtime == innerEndtime){
                                //newArry.push(tempArry.splice(innerCnt,1));
                                newArry.push(loopArray[innerCnt]);
                                indexArray.push(innerCnt);
                            }else if(outerstartTime  < innerStartTime && outerendtime > innerEndtime){
                                //newArry.push(tempArry.splice(innerCnt,1));
                                newArry.push(loopArray[innerCnt]);
                                indexArray.push(innerCnt);
                            }else if(outerstartTime > innerStartTime && outerendtime > innerEndtime && innerEndtime > outerstartTime){
                                //newArry.push(tempArry.splice(innerCnt,1));
                                newArry.push(loopArray[innerCnt]);
                                loopArray[innerCnt].isChild=true;
                                //indexArray.push(innerCnt);
                            }else if(outerstartTime < innerStartTime && outerendtime < innerEndtime && innerStartTime < outerendtime){
                                //newArry.push(tempArry.splice(innerCnt,1));
                                newArry.push(loopArray[innerCnt]);
                                loopArray[innerCnt].isChild=true;
                                //indexArray.push(innerCnt);
                            }else if(outerstartTime == innerStartTime && outerendtime < innerEndtime){
                                newArry.push(loopArray[innerCnt]);
                                loopArray[innerCnt].isChild=true;
                            }else if(outerstartTime > innerStartTime && outerendtime == innerEndtime){
                                newArry.push(loopArray[innerCnt]);
                                loopArray[innerCnt].isChild=true;
                    //newArry.push(tempArry.splice(k,1));
                    indexArray.push(k);
                    newArry.push(loopArray[k]);
                    __sortedArrayCollection.addItem(newArry);                   
                copyArry=loopArray.concat();
                loopArray=new Array();
                for (var j:int=0;j<copyArry.length;j++){
                    if(indexArray.indexOf(j) < 0){
                        loopArray.push(copyArry[j]);
                indexArray=new Array();               
        private function arrayClone(source:Array):Array{
            var returnArray:Array=new Array();
            for(var j:int=0;j<source.length;j++){
                returnArray.push(source[j]);
            return returnArray;
        public function set currentDate(inputVal:Date):void{
            if(__currentDate != inputVal){
                __currentDate=inputVal;
        public function get currentDate():Date{
            return __currentDate;
        public function set apptDataArray(inputVal:Array):void{
            if(!__dataProviderChanged && inputVal.length > 0){
                __apptDataInfoArry=inputVal;
                __dataProviderChanged=true;
                invalidateProperties();
                invalidateDisplayList();
AppointmentDisplayBox.as
package layouts.DayViewControl
    import mx.controls.TextInput;
    import mx.core.UIComponent;
    public class AppointmentDisplayBox extends UIComponent
        private var __startTime:String;
        private var __EndTime:String;
        private var __currentDate:Date;
        private var __apptData:XML;
        private var __height:Number;
        private var __isChild:Boolean=false;
        private var __modifiedWidth:Boolean=false;
        private var __docNameLable:TextInput;
        private var __appDetails:TextInput;
        public function AppointmentDisplayBox()
            super();
            this.setStyle("horizontalScrollPolicy","off");
            this.setStyle("verticalScrollPolicy","off");
            this.setStyle("borderStyle","solid");
            this.setStyle("verticalGap","0");
            this.setStyle("borderStyle","outset");       
            this.buttonMode=true;           
        protected override function createChildren():void{
            super.createChildren();
            if(!__docNameLable){
                __docNameLable=new TextInput();
                __docNameLable.editable=false;
                __docNameLable.setStyle("horizontalScrollPolicy","off");
                __docNameLable.setStyle("verticalScrollPolicy","off");
                __docNameLable.setStyle("borderStyle","none");
                //__docNameLable.setStyle("borderThickness","0");
                __docNameLable.buttonMode=true;
                addChild(__docNameLable);
            if(!__appDetails){
                __appDetails=new TextInput();
                __appDetails.editable=false;   
                __appDetails.setStyle("horizontalScrollPolicy","off");
                __appDetails.setStyle("verticalScrollPolicy","off");
                __appDetails.setStyle("borderStyle","none");
                 __appDetails.setStyle("backgroundColor","0xB1FB17");
                 __appDetails.buttonMode=true;
            //    __appDetails.setStyle("borderThickness","0");
                addChild(__appDetails);
        protected override function commitProperties():void{
            super.commitProperties();
             if(__apptData != null){
                __docNameLable.text=__apptData.DocName.toString();
                __appDetails.text=__apptData.PatientID.toString()+"\n"+__apptData.Description.toString();                
                invalidateDisplayList();
        protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
            super.updateDisplayList(unscaledWidth,unscaledHeight);
            __docNameLable.setActualSize(unscaledWidth-1,20);
            __docNameLable.move(1,1);
            graphics.clear();
            var lineColor:uint=0x000000;
            graphics.lineStyle(1,lineColor,1);
            graphics.beginFill(0xFEFDFD,1)
            graphics.drawRect(0,0,unscaledWidth,22);
            graphics.endFill();
            __appDetails.setActualSize(unscaledWidth-1,unscaledHeight-22);
            __appDetails.move(1,23);
            graphics.drawRect(0,22,unscaledWidth,unscaledHeight-20);
        public function set startTime(inputVal:String):void{
            __startTime=inputVal;
        public function get startTime():String{
            return __startTime;
        public function set endTime(inputVal:String):void{
            __EndTime=inputVal;
        public function get endTime():String{
            return __EndTime;
        public function set currentDate(inputVal:Date):void{
            __currentDate=inputVal;
        public function get currentDate():Date{
            return __currentDate;
        public function set apptHeight(inputVal:Number):void{
            __height=inputVal;
        public function get apptHeight():Number{
            return __height;
        public function set isChild(inputVal:Boolean):void{
            __isChild=inputVal;
        public function get isChild():Boolean{
            return __isChild;
        public function set isModifiedWidth(inputVal:Boolean):void{
            __modifiedWidth=inputVal;
        public function get isModifiedWidth():Boolean{
            return __modifiedWidth;
        public function set apptDataXml(inputVal:XML):void{
            if(__apptData != inputVal){
                __apptData=inputVal;
                invalidateProperties();
                invalidateDisplayList();
        public function get apptDataXml():XML{
            return __apptData;
Test.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:layouts="layouts.*"
    xmlns:DayViewControl="layouts.DayViewControl.*" xmlns:test="layouts.DayViewControl.containers.*">
    <mx:Script>
        <![CDATA[
            import mx.controls.TextInput;
            import layouts.DayViewControl.TimeDividerLines;
            import mx.events.DragEvent;
            import mx.managers.DragManager;
            import mx.core.DragSource;
            import layouts.DayViewControl.AppointmentDisplayBox;
            private function mouseDownHandler(event:MouseEvent):void{
                var dragint:AppointmentDisplayBox=AppointmentDisplayBox(event.currentTarget);
                //var dragint:TextInput=TextInput(event.currentTarget);
                var ds:DragSource=new DragSource();
                ds.addData(dragint,"Appoitment");
                DragManager.doDrag(dragint,ds,event);               
            private function dragEnterHandler(event:DragEvent):void{
                if(event.dragSource.hasFormat("Appoitment")){
                    var droptarget:TimeDividerLines=TimeDividerLines(event.currentTarget);
                    DragManager.acceptDragDrop(droptarget);
                    DragManager.showFeedback(event.ctrlKey?DragManager.COPY:DragManager.MOVE);
                    return;
                DragManager.showFeedback(DragManager.NONE);
            private function dragDropHandler(event:DragEvent):void{
                if(event.dragSource.hasFormat("Appoitment")){
                    var droppedObj:AppointmentDisplayBox=AppointmentDisplayBox(event.dragSource.dataForFormat("Ap poitment"));
                    //var droppedObj:TextInput=TextInput(event.dragSource.dataForFormat("Appoitment"));
                    var dropTarget:TimeDividerLines=TimeDividerLines(event.currentTarget);
                    droppedObj.x=dropTarget.mouseX;
                    droppedObj.y=dropTarget.mouseY;
                    dropTarget.addChild(droppedObj);
        ]]>
    </mx:Script>
    <mx:HBox width="100%" height="100%">
        <DayViewControl:TimeDividerLines width="50%" height="100%">
            <DayViewControl:AppointmentDisplayBox width="50" height="100" mouseDown="mouseDownHandler(event)"/>
        </DayViewControl:TimeDividerLines>
        <DayViewControl:TimeDividerLines width="50%" height="100%" dragEnter="dragEnterHandler(event)" dragDrop="dragDropHandler(event)"/>
    </mx:HBox>
</mx:Application>

First 3 .as are the component
source. in the last test.mxml file i have written the drag and drop functionality.
can any help me?? please

Similar Messages

  • How can I learn "Drag and Drop" with Swing components?

    Hello,
    Im using swing components, so using paint() to draw a "drag icon" doesnt seem acceptable. Im basically trying to move a JPanel image to be dragged/dropped over another JPanel in the same program/applet.
    I looked at Sun's Java Tutorial for information on doing drag and drop, but there was no trail completed yet.
    Does anyone know of any good resources to learn? Or can at least give me a general idea of how to do drag and drop?

    Did you see this?
    http://java.sun.com/docs/books/tutorial/dnd/index.html
    http://java.sun.com/docs/books/tutorial/reallybigindex.html

  • Drag and Drop of multiple components at once

    Hi everybody,
    I need to select and drag multiple components (Eg. JLabels) at once, it is quite simple to manage just one drag at a time but how can be managed a multiple drag?
    I mean something like Windows files selection mechanism : using Ctrl + Left mouse click to select the components and then start dragging them all to the drop target.
    Beneath the code I'm using for testing , clicking and dragging each JLabel to JTextField just cause the copy of JLabel text to the JTextField contents.
    In the sample a left click on each displayed label sets a border just to identify the selected status of the labels to drag but there's no implementation of the drop mechanism that should copy all the selected JLabels text to the drop target (the JTextField).
    import java.awt.Dimension;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.util.HashMap;
    import javax.swing.BorderFactory;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.TransferHandler;
    import javax.swing.UIManager;
    import javax.swing.border.Border;
    import javax.swing.border.CompoundBorder;
    import javax.swing.border.EmptyBorder;
    public class SelectableJLabel extends JPanel {
      MouseListener listener = new DragMouseAdapter();
      public Border getBorder(boolean getSelectedBorder) {
        Border outsideBorder = BorderFactory.createEmptyBorder(2,2,2,2);
        Border insideBorder = BorderFactory.createEmptyBorder(2,2,2,2);
        if (getSelectedBorder)
          insideBorder = BorderFactory.createEtchedBorder();
        return BorderFactory.createCompoundBorder(outsideBorder, insideBorder);
      private class DragMouseAdapter extends MouseAdapter {
        public void mousePressed(MouseEvent e) {
          System.out.println("Press!");
          JComponent c = (JComponent) e.getSource();
          JLabel lbl = (JLabel)c;     
          if (lbl.getBorder()==null || ((CompoundBorder)lbl.getBorder()).getInsideBorder() instanceof EmptyBorder) {
            lbl.setBorder(getBorder(true));
            TransferHandler handler = c.getTransferHandler();
            handler.exportAsDrag(c, e, TransferHandler.COPY);    
          } else
            lbl.setBorder(getBorder(false));        
        /* (non-Javadoc)
         * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
        @Override
        public void mouseClicked(MouseEvent e) {
      public JLabel getSelectableLabel() {
        JLabel selectableJLabel = new JLabel("You can't select me");
        selectableJLabel.setBorder(getBorder(false));
        selectableJLabel.setTransferHandler(new TransferHandler("text"));
        selectableJLabel.addMouseListener(listener);
        return selectableJLabel;
      public SelectableJLabel() {
        // a regular JLabel
        add(getSelectableLabel());
        add(getSelectableLabel());
        add(getSelectableLabel());
        // a look-alike JLabel
        JTextField f = new JTextField("You can select me........................");
        f.setDragEnabled(true);
        //f.setEditable(false);
        f.setBorder(null);
        f.setForeground(UIManager.getColor("Label.foreground"));
        f.setFont(UIManager.getFont("Label.font"));
        add(f);
      public Dimension getPreferredSize() {
        return new Dimension(100, 100);
      public static void main(String s[]) {
        JFrame frame = new JFrame("SelectableJLabel");
        SelectableJLabel panel = new SelectableJLabel();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(panel, "Center");
        frame.setSize(panel.getPreferredSize());
        frame.setVisible(true);
    }Tnx in advance for HELP
    Massimo
    Edited by: JKut on May 2, 2010 10:48 AM

    For multiple selections I recommend to use "JList". The "ListTransferHandler" provided in the "DropDemo" sample code supports multiple selections: [http://java.sun.com/docs/books/tutorial/uiswing/dnd/dropmodedemo.html]. To enable MULTIPLE_INTERVAL_SELECTION, simply remove the following statement in the "DropDemo" class:
            list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

  • Drag and drop custom object

    Hello,
    I am trying to create a GUI where the user will be able to drag an object (which I have created) from a toolbar button onto a JPanel. I have tried the sun tutorials to no avail. I am unsure exactly what code I should be writing to enable this functionality. I have written a dragmouseadapter which enables drag and drop from the button. I have also written a TransferHandler and Transferable for the object, but again I'm not sure how I should be using these. Can anyone advise me? Hopefully in a sort of step-by-step instruction for setting this up. Thank you.

    You wanted to drag and drop a custom component and you said its done using dragmouseadapter!
    TransferHandler and Transferable are used to transfer the data between the swing components.
    Now, what you want to do? So, we can help!

  • Hi,  This was not what I meant.     The requirement is:      Drag and drop any one of specific list

    Hi,
    This was not what I meant.
    The requirement is:
    Drag and drop any one of specific list of components say x, y,z in the parsys
    Only after the drag and drop of these components other components can be dragged to the parsys. So we can say that the parsys should allow only the specific components to be added first and only after that other components can be added.
    Thanks ,
    Dipti

    Hi there
    I'm guessing that you mean to ask if one is able to force a user to perform a drag-and-drop as part of a simulation?
    Unless you program it in Flash or some other application it isn't avaiable. Check the link below for more.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Can you use a custom cursor with drag and drop?

    Hi there! I'm a newbie flash user and working on a simulation for a graduate course in instructional design. I'm using Flash Professional CC on Mac. Here's what I'm trying to do. I have several draggable sprites on the stage and three target sprites. I have specified the original x,y locations of the sprites and have set the end x,y locations as those of each of the three targets. Items must be dragged to one of the three targets.
    Some questions:
    1. Can I specify more than one End x,y location for a draggable sprite? I'm creating a lesson to teach kindergartners how to sort lunchroom waste. If they have a napkin, for example, it could either go into the compost OR into the recycling. In cases like this where an item could really be placed into more than one bin, I want them to get it right if they do either of those things, rather than forcing them to choose which one.
    2. To make my project more "fun" for kids, I wanted to customize the cursor with a graphic of  hand. When I tried this in the flash file it works perfectly until I add the drag and drop functionality for the wasted items. Then the cursor will more around  but not pick up any items. Once I revert back to the standard pointer, the correct drag and drop functionality is restored.
    3. I have it set to snap back to the original location if learner attempts to drop the item on the wrong target. I want to be able to play a sound file when that happens, as well as play a sound file when it lands on the correct target, as well as shrink the item and change its opacity so that it appears invisible. I want to give the illusion of it being placed into the bin. I have no idea as to the proper way to code these events so that they happen.
    4. I've watched dozens of hours of youtube tutorials before coming here. I'm a quick study, but am very new to action script. In one of the videos the developer showed referencing an external action script file which I don't think is an option in CC. The coding method he used seemed much more streamlined and "clean" than the chunks I'm working with now. Is there an easy way for me to code information about these objects  than the way I've got it here now? I hate starting new things with bad habits. The perils of self-teaching.
    Thanks!
    I'm pasting my code from the actions panel below so you can see what's going on:
    stop();
    /* Custom Mouse Cursor
    Replaces the default mouse cursor with the specified symbol instance.
    stage.addChild(customcursor);
    customcursor.mouseEnabled = false;
    customcursor.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);
    function fl_CustomMouseCursor(event:Event)
      customcursor.x = stage.mouseX;
      customcursor.y = stage.mouseY;
    Mouse.hide();
    //To restore the default mouse pointer, uncomment the following lines:
    customcursor.removeEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);
    stage.removeChild(customcursor);
    Mouse.show();
    //set up variables and objects for dragging
    var offset:int = 10;
    var appleStartX:int = 243;
    var appleStartY:int = 156;
    var appleEndX:int = 522;
    var appleEndY:int = 22;
    apple.buttonMode = true;
    apple.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    apple.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var cupStartX:int = 39;
    var cupStartY:int = 266;
    var cupEndX:int = 520;
    var cupEndY:int = 175;
    cup.buttonMode = true;
    cup.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    cup.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var barStartX:int = 178;
    var barStartY:int = 234;
    var barEndX:int = 522;
    var barEndY:int = 22;
    bar.buttonMode = true;
    bar.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    bar.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var orangeStartX:int = 284;
    var orangeStartY:int = 102;
    var orangeEndX:int = 522;
    var orangeEndY:int = 22;
    orange.buttonMode = true;
    orange.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    orange.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var bottleStartX:int = 172;
    var bottleStartY:int = 303;
    var bottleEndX:int = 520;
    var bottleEndY:int = 175;
    bottle.buttonMode = true;
    bottle.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    bottle.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var bananaStartX:int = 113;
    var bananaStartY:int = 123;
    var bananaEndX:int = 522;
    var bananaEndY:int = 22;
    banana.buttonMode = true;
    banana.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    banana.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var napkinStartX:int = 248;
    var napkinStartY:int = 271;
    var napkinEndX:int = 520;
    var napkinEndY:int = 175;
    napkin.buttonMode = true;
    napkin.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    napkin.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var yogurtStartX:int = 27;
    var yogurtStartY:int = 136;
    var yogurtEndX:int = 518;
    var yogurtEndY:int = 329;
    yogurt.buttonMode = true;
    yogurt.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    yogurt.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var strawberryStartX:int = 120;
    var strawberryStartY:int = 285;
    var strawberryEndX:int = 522;
    var strawberryEndY:int = 22;
    strawberry.buttonMode = true;
    strawberry.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    strawberry.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var sandwichStartX:int = 7;
    var sandwichStartY:int = 364;
    var sandwichEndX:int = 522;
    var sandwichEndY:int = 22;
    sandwich.buttonMode = true;
    sandwich.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    sandwich.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var juiceStartX:int = 88;
    var juiceStartY:int = 347;
    var juiceEndX:int = 518;
    var juiceEndY:int = 329;
    juice.buttonMode = true;
    juice.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    juice.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var foilStartX:int = 39;
    var foilStartY:int = 416;
    var foilEndX:int = 520;
    var foilEndY:int = 175;
    foil.buttonMode = true;
    foil.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    foil.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var waxbagStartX:int = 235;
    var waxbagStartY:int = 342;
    var waxbagEndX:int = 522;
    var waxbagEndY:int = 22;
    waxbag.buttonMode = true;
    waxbag.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    waxbag.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    function startDragging (e:MouseEvent) {
      e.currentTarget.startDrag();
    function stopDragging (e:MouseEvent) {
      e.currentTarget.stopDrag();
      switch (e.currentTarget) {
      case apple:
      if (apple.x < appleEndX - offset || apple.x > appleEndX + offset || apple.y < appleEndY - offset || apple.y > appleEndY + offset) {
      apple.x = appleStartX;
      apple.y = appleStartY;
      else {
      apple.x = appleEndX;
      apple.y = appleEndY;
      //checkGame();
      break;
      case sandwich:
    if (sandwich.x < sandwichEndX - offset || sandwich.x > sandwichEndX + offset || sandwich.y < sandwichEndY - offset || sandwich.y > sandwichEndY + offset) {
      sandwich.x = sandwichStartX;
      sandwich.y = sandwichStartY;
      else {
      sandwich.x = sandwichEndX;
      sandwich.y = sandwichEndY;
      //checkGame();
      break;
      case orange:
    if (orange.x < orangeEndX - offset || orange.x > orangeEndX + offset || orange.y < orangeEndY - offset || orange.y > orangeEndY + offset) {
      orange.x = orangeStartX;
      orange.y = orangeStartY;
      else {
      orange.x = orangeEndX;
      orange.y = orangeEndY;
      //checkGame();
      break;
      case strawberry:
    if (strawberry.x < strawberryEndX - offset || strawberry.x > strawberryEndX + offset || strawberry.y < strawberryEndY - offset || strawberry.y > strawberryEndY + offset) {
      strawberry.x = strawberryStartX;
      strawberry.y = strawberryStartY;
      else {
      strawberry.x = strawberryEndX;
      strawberry.y = strawberryEndY;
      //checkGame();
      break;
      case napkin:
    if (napkin.x < napkinEndX - offset || napkin.x > napkinEndX + offset || napkin.y < napkinEndY - offset || napkin.y > napkinEndY + offset) {
      napkin.x = napkinStartX;
      napkin.y = napkinStartY;
      else {
      napkin.x = napkinEndX;
      napkin.y = napkinEndY;
      //checkGame();
      break;
      case bar:
    if (bar.x < barEndX - offset || bar.x > barEndX + offset || bar.y < barEndY - offset || bar.y > barEndY + offset) {
      bar.x = barStartX;
      bar.y = barStartY;
      else {
      bar.x = barEndX;
      bar.y = barEndY;
      //checkGame();
      break;
      case juice:
    if (juice.x < juiceEndX - offset || juice.x > juiceEndX + offset || juice.y < juiceEndY - offset || juice.y > juiceEndY + offset) {
      juice.x = juiceStartX;
      juice.y = juiceStartY;
      else {
      juice.x = juiceEndX;
      juice.y = juiceEndY;
      //checkGame();
      break;
      case foil:
    if (foil.x < foilEndX - offset || foil.x > foilEndX + offset || foil.y < foilEndY - offset || foil.y > foilEndY + offset) {
      foil.x = foilStartX;
      foil.y = foilStartY;
      else {
      foil.x = foilEndX;
      foil.y = foilEndY;
      //checkGame();
      break;
      case banana:
    if (banana.x < bananaEndX - offset || banana.x > bananaEndX + offset || banana.y < bananaEndY - offset || banana.y > bananaEndY + offset) {
      banana.x = bananaStartX;
      banana.y = bananaStartY;
      else {
      banana.x = bananaEndX;
      banana.y = bananaEndY;
      //checkGame();
      break;
      case bottle:
    if (bottle.x < bottleEndX - offset || bottle.x > bottleEndX + offset || bottle.y < bottleEndY - offset || bottle.y > bottleEndY + offset) {
      bottle.x = bottleStartX;
      bottle.y = bottleStartY;
      else {
      bottle.x = bottleEndX;
      bottle.y = bottleEndY;
      //checkGame();
      break;
      case waxbag:
    if (waxbag.x < waxbagEndX - offset || waxbag.x > waxbagEndX + offset || waxbag.y < waxbagEndY - offset || waxbag.y > waxbagEndY + offset) {
      waxbag.x = waxbagStartX;
      waxbag.y = waxbagStartY;
      else {
      waxbag.x = waxbagEndX;
      waxbag.y = waxbagEndY;
      //checkGame();
      break;
      case cup:
    if (cup.x < cupEndX - offset || cup.x > cupEndX + offset || cup.y < cupEndY - offset || cup.y > cupEndY + offset) {
      cup.x = cupStartX;
      cup.y = cupStartY;
      else {
      cup.x = cupEndX;
      cup.y = cupEndY;
      //checkGame();
      break;
      case yogurt:
    if (yogurt.x < yogurtEndX - offset || yogurt.x > yogurtEndX + offset || yogurt.y < yogurtEndY - offset || yogurt.y > yogurtEndY + offset) {
      yogurt.x = yogurtStartX;
      yogurt.y = yogurtStartY;
      else {
      waxbag.x = waxbagEndX;
      waxbag.y = waxbagEndY;
      //checkGame();

    Some questions:
    1. Can I specify more than one End x,y location for a draggable sprite?
    yes, use an if-else statement
    I'm creating a lesson to teach kindergartners how to sort lunchroom waste. If they have a napkin, for example, it could either go into the compost OR into the recycling. In cases like this where an item could really be placed into more than one bin, I want them to get it right if they do either of those things, rather than forcing them to choose which one.
    2. To make my project more "fun" for kids, I wanted to customize the cursor with a graphic of  hand. When I tried this in the flash file it works perfectly until I add the drag and drop functionality for the wasted items. Then the cursor will more around  but not pick up any items. Once I revert back to the standard pointer, the correct drag and drop functionality is restored.
    assign your cursor's mouseEnabled property to false:
    yourcursor.mouseEnabled=false;
    3. I have it set to snap back to the original location if learner attempts to drop the item on the wrong target. I want to be able to play a sound file when that happens, as well as play a sound file when it lands on the correct target, as well as shrink the item and change its opacity so that it appears invisible. I want to give the illusion of it being placed into the bin. I have no idea as to the proper way to code these events so that they happen.
    use the sound class to create a sound:
    // initialize your correct sound once with
    var correctSound:Sound=new CorrectSound();  // add an mp3 sound to your library and assign it class = CorrectSound
    // apply the play() method everytime you want your sound to play:
    correctSound.play();
    // change an object's opacity:
    someobject.alpha = .3;  // partially visible
    someobject.alpha = 1;  // fully visible
    someobject.visible=false;  // not visible, at all.
    // change an object's scale
    someobject.scaleX=someobject.scaleY=.5;  // shink width and height by 2
    someobject.scaleX=someobject.scaleY=1;  // resize to original
    4. I've watched dozens of hours of youtube tutorials before coming here. I'm a quick study, but am very new to action script. In one of the videos the developer showed referencing an external action script file which I don't think is an option in CC. The coding method he used seemed much more streamlined and "clean" than the chunks I'm working with now. Is there an easy way for me to code information about these objects  than the way I've got it here now? I hate starting new things with bad habits. The perils of self-teaching.
    you could google: 
    actionscript 3 class coding
    actionscript 3 object oriented programming
    p.s.  you can simplify and streamline your coding by learning about arrays and using hitTestObject.

  • Implementing drag and drop across components with drag image...

    Hey all,
    Finally got the hang of drag and drop. Not too hard, but a little time consuming. I found an article showing how to capture and drag a BufferedImage within a JTree. When you click and drag a node, it creates a BufferedImage of the node on screen and "ghosts" it a bit, which has a very appealing effect.
    However, when I try to drag this image to a JList component, it disappears. So I created the same affect in the JList component. Now you can drag the image from the tree to the list and vice versa. However, the problem is, the image does not "fly over" the borders of the two components (butted up against each other) with the mouse. The image seems to go under the borders, while the mouse floats above everything.
    What I would like to do is be able to drag the image all over the application, perhaps even the desktop in the case of a SDI application. I want to be able to see this image drag from my Java app over the Windows Explorer folder, just like how you can do that with Windows Explorer, dragging an image of the selected node into any app that supports the drop. I know we can handle the "transfer" data from explorer and vice versa, but how to be able to keep an image with the mouse?
    My best guess is somehow using the Glass pane, grabbing a ref to its BufferedImage (if that is even what is there), and drawing the dragged item in that pane. But, then, how will the image move over the desktop outside of the app, where a glass pane is not?
    Is there a way to draw on top of anything, anywhere, but still be able to redraw the background as the image moves with the mouse? There are times where the image may be big, so I don't want to have to capture the underlying screen as an image covering the size of the drag image to restore it as the drag image moves around.
    Thank you.

    We know cursors support some degree of transparence because they have shapes other than blocks.
    I've done some playing around with
    Toolkit.getDefaultToolkit().createCustomCursor(....);The sad news is, it seems that as soon as a pixel's alpha value is greater than 0, it automatically becomes 100% opaque.
    The best you can do, is to take your image, and divide it into a pixel-checkerboard, and set the alpha value of alternating pixels to 0.
    e.g.
    BufferedImage i = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
            int[] data = ((DataBufferInt)i.getRaster().getDataBuffer()).getData();
            boolean on = true;
            for (int z=0; z<data.length; z++)
                if (on)
                    data[z] = 0xffffffff;
                else
                    data[z] = 0x00000000;
                on = !on;
                if (z%32==0) on = !on;
            Cursor hazyWhite = Toolkit.getDefaultToolkit().createCustomCursor(i, new Point(0,0), "hw");

  • Custom Drag and Drop Component: When i add a skin, drag and drop no longer works?

    I have a skinnableContainer that acts as a container for other drag and droppable items. This container's drop functionality is added from it's parent at the same moment the container is added.
    This all works fine until i add a skin class to the skinnableContainer, now none of the draggable items can drop into the container as it did before.
    I assume that the Group component wrapping the content from within the skin is acting as a block somehow, but i'm not sure how to allow the drop functionality through it?
    Any ideas? Thanks in advance.

    Hello,
    Thanks for your replies... I tried modifying the if clause,
    but it did not work. I can use a trace statement to find out what
    the target is and what level it is at, but I cannot do this when it
    is in our presenter window.
    The code that is causing the problem can be accessed right in
    Flash. Just create a new quiz, then in the library, go to Quiz
    Files --> Learning Interactions --> Assets --> Controls
    --> Components, right click on drag and drop and select edit and
    then go to the actions frame. I am sure you already know this, but
    I just want to be clear I did not make this from scratch.
    This code works great when the quiz is the root movie. But if
    the quiz is encapsulated within another movie, it does not work. I
    can drag the objects, but they just snap back to where their
    starting points are. In the code I attached earlier...
    "this._parent.Target1" used to be "target".
    Just so you can see it all, I have attached the problematic
    function.
    What happens is that if "this._parent.Target1" is set to
    "target", the movie will function fine in Flash, but will not work
    in our presentation window. I can drag the draggable objects, but
    they always snap back to the location of where they came from.
    What this means is that the if clauses are not being run, and
    the function is always running the else clause, which puts all of
    the objects back at their starting point.
    In the code attached, I am using "this._parent.Target1".
    Again, works fine in Flash, but when I put it in the presentation
    window, this time, I can drag the objects anywhere on the screen,
    but when I drop them, they think that the dropZone is the question
    itself, and not the Target (Target1). So I need to figure out how
    to make Target1 be the dropZone in our presentation window.
    Any ideas?
    Thanks again for all your help!

  • ADF Button components: How to disable drag and drop [SOLVED]

    Hi everyone
    I need to develop an application which allows not the user to drag and drop button components. I've converted every single af:commandbutton to h:commandbutton, to prevent this behaviour, but a huge lot of other problems arose from this "solution". I'm using JDeveloper 10.1.3.3.0.4157, and I'm a beginner, so please be patient with me.
    Thanks in advance.

    Maybe I've drifted off-topic with this, but I found the way to achieve this. The only limitation is that the change must be done on the client's computer. The drag and drop feature can be disabled by going to the about:config page in Firefox, and setting nglayout.enable_drag_images to false. It can also be done in a more "portable" way by creating a user.js script in the profile folder and setting it from there. Thank you all for stopping by and reading.

  • Drag and Drop using Components[

    Hi,
    As anyone used Drag and Drop for components? I mean, allowing the user to drag and drop a component around a container? Just curious, so far from what I've seen, the only things that can be dragged/dropped are properties of a given object, such as 'text" from a JLabel.
    thanks

    IMHO, you don't need fancy drag and drop features to do that. Implementing MouseInputListener and listening for mouseDragged is a good start. Then setting the component's bounds depending on the location of the mouse at the mouseReleased event (wrt the starting offset) could be a good idea (if you're using absolute positioning, of course).
    From there, it all depends on what you want it to look like during the "transfer". You could, for instance paint the component in a BufferedImage at the start of the D&D and then paint the image with transparency as the mouse is moving.
    Camickr had an interesting post that might help you :
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=492100

  • Programatic Generation and positioning of  components using Drag and Drop

    Hi,
    I am relatively new to ADF and UI Designing. Im trying to generate a flowchart using drag and drop feature in ADF. This involves creation of dragging images such as start,decision .. etc from one panel to another and dynamically creating a flowchart.
    Up to now i have managed to drag images from panel1 to panel2 and create them dynamically in the bean class. However im stuck at this point .. Im not able to position the draggable components on the desired position in the panelGroup. They either appear horizontally or vertically.
    Is there any way to achieve this. Also is it possible to assign a dropTarget to a a target component which is created dynamically ?
    Thanks in anticipation ....
    Lyle

    Hi Lyle,
    I am too only 4 months old to adf ,i use jdeveloper 10g.
    In 10g for the components to be placed at desired locations i think is somewhat possible. While you can arrange them by using spaces which causes
    f:verbatim tag to appear or you can use ADF Faces Core items like Object Spacer and Object Seperator where you can set their length and width to space objects on page...
    Regards
    Rohit

  • Drag and drop to create a custom step

    Hi,
    I have a custom insertion palette in my custom user-interface. I want to allow the user to drag the step from the custom insertion palette into the sequence designer, like the original insertion palette. The custom insertion palette is in WPF.
    The data format for the drag and drop object is
    e.Data.GetFormats()
      {string[1]}
        [0]: "SeqEditor New Step Binary"
    The data is actually a MemoryStream:
    e.Data.GetData(e.Data.GetFormats()[0])
      {System.IO.MemoryStream}
        base {System.IO.Stream}: {System.IO.MemoryStream}
        CanRead: true
        CanSeek: true
        CanWrite: true
        Capacity: 6936
        Length: 6936
        Position: 0
    So it's actually some Unicode text if I read it with StreamReader:
    new StreamReader((Stream)e.Data.GetData(e.Data.GetFormats()[0]),Encoding.Unicode).ReadToEnd()
    "E@=3@JKZ100h\\L]JDYcLO7e9@FLU:h9iM]>5Uf16W>Hii091DHkYGJKJHMd[<...
    What's the proper way for me to implement the drag and drop feature for my custom insertion palette? I'm thinking to create a similar MemoryStream but I can't understand the format of the data.
    Thanks.
    Solved!
    Go to Solution.

    Please note that the clipboard format is not something we intend for users to create directly, and it might change in a future version of TestStand. So, if you do this, keep in mind it's possible it might not work in a future version of TestStand (i.e. we do not support creating clipboard items directly).
    That said, it might be possible to get it to work in current versions of TestStand as follows (I haven't tried to do exactly what you are doing, but here is how our format is currently generated):
    PropertyObject[] stepPropObjects = new PropertyObject[1];
    Step newStep = templateOfStep.AsPropertyObject().Clone("", PropertyOptions.PropOption_CopyAllFlags | PropertyOptions.PropOption_DoNotShareProperties) as Step;
    newStep.CreateNewUniqueStepId();
    stepPropObjects[0] = newStep as PropertyObject;
    DataObject dataObject = new DataObject();
    DataFormats.Format stepFormat = DataFormats.GetFormat("SeqEditor New Step Binary");
    string serializedPropertyObject = this.Engine.SerializeObjects(stepPropObjects, SerializationOptions.SerializationOption_UseBinary);
    serializedPropertyObject += "F"; // False for isEditCut (thus unique ID's will be created on paste).
    System.Text.UnicodeEncoding encodingForStrConv = new System.Text.UnicodeEncoding();
    byte[] buffer = encodingForStrConv.GetBytes(serializedPropertyObject);
    MemoryStream vvClipData = new MemoryStream(buffer);
    dataObject.SetData(stepFormat.Name, false, vvClipData);
    Hope this helps,
    -Doug

  • Drag And Drop operations do not call custom IRM Protector

    We are developing our own custom IRM Protector, 
    So far we have successfuly integrated our IRM Protector into Sharepoint, and download operations and upload operations do protect and unprotect documents. Also move operations between libraries, through Send To ribbon action, call HrProtect and HrUnprotect
    methods as needed. 
    However, in our test environments, when using drag and drop operations between Libraries or folders, the IRM Protector is not being called at all. We have tried to update our test environments to the latest Cumulative Update, without success. Is there any
    known bug around the drag and drop functionality? 
    If true, Drag and Drop suposes a great security threat, and we cannot deliver our protection product to our customers, as it would mean document protections could be bypassed by a simple sharepoint operation.
    Thanks,

    We are developing our own custom IRM Protector, 
    So far we have successfuly integrated our IRM Protector into Sharepoint, and download operations and upload operations do protect and unprotect documents. Also move operations between libraries, through Send To ribbon action, call HrProtect and HrUnprotect
    methods as needed. 
    However, in our test environments, when using drag and drop operations between Libraries or folders, the IRM Protector is not being called at all. We have tried to update our test environments to the latest Cumulative Update, without success. Is there any
    known bug around the drag and drop functionality? 
    If true, Drag and Drop suposes a great security threat, and we cannot deliver our protection product to our customers, as it would mean document protections could be bypassed by a simple sharepoint operation.
    Thanks,

  • Drag and drop components

    hi folks,
    am using jdev 11.1.1.5.0 - adfbc.
    when am i wondering about drag and drop components in ADF 11g.
    i get some of the example.
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/60-table-drag-n-drop-sample-176981.pdf
    http://www.baigzeeshan.com/2011/01/drag-and-drop-collection-in-oracle-adf.html
    http://www.baigzeeshan.com/2010/07/implementing-drag-and-drop-functionaly.html
    http://www.gebs.ro/blog/oracle/adf-drag-and-drop-hints/
    http://www.gebs.ro/blog/oracle/oracle-adf-overcome-adf-restrictions-on-copying-components-with-drag-n-drop/
    ok fine. is there any other links. make more interactive in UI
    need is :
    make my user to feel free use my application.

    What about the product documentation ?
    http://docs.oracle.com/cd/E23943_01/web.1111/b31973/af_dnd.htm#CIHCHGIF
    Also, the following book:
    has a chapter (chapter 14) on drag and drop
    http://www.amazon.com/Oracle-Fusion-Developer-Guide-Applications/dp/0071622543/ref=sr_1_cc_1?s=aps&ie=UTF8&qid=1343975521&sr=1-1-catcorr&keywords=Oracle+Fusion+Developer+Guide
    Frank

  • Drag and Drop custom objects

    Hi guys.
    I just finished reading the Java tutorial on Drag and Drop at http://download.oracle.com/javase/tutorial/uiswing/dnd/index.html.
    Unfortunately, there is no note about how to drag and drop a custon object. There is something said on DataFlavor, but not enough to help me.
    So I would appreciate it if anyone could tell me the steps to follow when dragging and droping a custom object.
    Best regards.
    Edmond

    I think we can help you, but please post some example/code of what you are trying to achieve.
    I made D&D with custom objects, custom icons, etc. and is not so hard ... like I said, post some code ...
    RGV

Maybe you are looking for

  • I am trying to make a call to a dll to have labview return a buffer filled with data stored in an array. The proble

    m that I am having is that to do this I need to fill two different structures, one containing a pointer to a double, which I don't think I can do without perhaps a wrapper function. The biggest problem is that I don't know how to even go about doing

  • EA2: bug in package run/debug dialog

    The PL/SQL block is not (re)generated correctly when switching between implementations of an overloaded func/proc: Whenever you run/debug a package from sql developer a dialog box is opened in which you can select a TARGET (any of the public function

  • I d/led Photoshop Elements trial and when it finished the d/l it gave me an Error 101

    The installer stated that the extraction process failed, that I should check my HD for space...etc. I am the Admin, it was a personal directory in any case, and I disabled all Virus and Malware detectors for this D/L. Is it possible to just d/l the p

  • How to parse timestamp data

    Hi, I am not able to parse timestamp data. I am bringing this timestamp from AD through LDAP attribute through java code. I want date and time from this timestamp so that I can compare it with another date and time and get the difference between the

  • Organization determination

    Guys, We basically have just one Organization within oor company. Irrespective of which transaction we use or which business partner we use, I want this organization to be picked up. Can some one suggest what would be the best org rule to use? Ani