How to implement drag/drop ?

Hello,
I want to build a GUI showing the view of a weekly calendar.
(Days on the Y Axis and events for that day on the X axis)
I want to draw each event as a rectangle. Also, I want to be able to drag the rectangles, and draw
them using rubberbanding (i.e hold the left mouse button down and drag to create a new event)
Is it a good idea to use Java 2D to create the above kind of functionality ?
Or should I be trying AWT or Swing instead ?
I think it will be easier to get the click and mouse move events if I draw each event as an AWT component.
But I am not sure how I am going to be able to handle drawing the events at the exact co-ordinates if
I use AWT.
Basically, I am stuck on whether to choose Java 2D or to choose AWT/Swing ?
Please guide me through your experience.
Ajay

Hello,
I want to build a GUI showing the view of a weekly calendar.
(Days on the Y Axis and events for that day on the X axis)
I want to draw each event as a rectangle. Also, I want to be able to drag the rectangles, and draw
them using rubberbanding (i.e hold the left mouse button down and drag to create a new event)
Is it a good idea to use Java 2D to create the above kind of functionality ?
Or should I be trying AWT or Swing instead ?
I think it will be easier to get the click and mouse move events if I draw each event as an AWT component.
But I am not sure how I am going to be able to handle drawing the events at the exact co-ordinates if
I use AWT.
Basically, I am stuck on whether to choose Java 2D or to choose AWT/Swing ?
Please guide me through your experience.
Ajay

Similar Messages

  • How to implement Drag and Drop in trees

    Hi,
    I have two hierarchical tree in a form, i need to drag each nodes form one tree node and drop into another tree, how i possible. am using Forms 6i developer.

    Drag-n-Drop is only available in Forms by extending Forms with a Java Bean. In order to use a Java Bean in your form, your form MUST be web deployed; if you are using traditional Client/Server with your Forms 6i then there is no way to implement Drag-n-Drop.
    Take a look at: Drag 'n Drop - Oracle Forms PJC and Java Beans. This article was based on using Oracle Forms 9i so you might not be able to implement it in your Forms 6i app.
    Craig...

  • How to implement drag and drop functionality in a HTML5 webpage using touch events?

    Hi all,
         I need to create a webpage having two parts.One part is having set of SVG images into it and other part is having canvas.I need to drag those image onto the canvas allowing same image for multiple times and those images on the canvas are movable inside the canvas only. This webpage is only used in iphone or ipad like touching devices so I need to handle touch events.
         There is already jQuery plugin for drag drop functionality but it is not supported for touch events.
    It is only for desktop veriosns.So if you know about any jquery plugin let me know.
         So please help me to carry out this task.

    I have tried using the same but still not working.
    I have handled touch events like touchstart,touchend,touchmove.
    But the problem is when I drag the image from upperbox onto canvas, the clone of that image is creating but the image which I dragged on canvas gets vanished.
    I am creating clone because I want to add multiple images onto canvas.
    Atik

  • How do I drag & drop items to toolbar using iPad?

    How do I drag & drop items to toolbar using iPad?

    If you mean the Bookmarks Bar (not the toolbar above it) you can add items to that by choosing Bookmark from the Share icon (rectangle with arrow coming out of it) and then choosing to add the bookmark to the Bookmarks Bar section in the popup that appears.

  • How can I drag/drop a TITLE w/URL of a bookmark, not just the URL.

    In a previous version of either FF or Windows, I could drag/drop the TITLE w/URL of a FF bookmark.
    In 3.6 I can only d/d the URL.
    Can I change it so I d/d the TITLE w/URL as a hyperlink?

    Good questions...  I'll have to try and figure out when the problem first happened - I was thinking it was when I upgraded to Safari 5.1.4 but that might not be the case...  I'll try your suggestions to see if any of them eliminate the problem (I have restarted recenlty and that didn't fix it) but I'll try repairing permissions,etc.  Thanks!
    hmmm... Mcbuffy: are you implying that you *don't* get the webloc when dragging an image out of Safari and that this isn't a caused by change to Safari but is a big/conflict in mine?

  • How to improve Drag&Drop?

    Hey guys,
    we have a graphical editor that we realized with GEF. In this graphical editor you are able to create a process by dragging and dropping elements from the palette and connecting them.
    One nice feature we have is to drag and drop an element on a transition which inserts this element on this position in the "chain".
    The problem we have is that the area to drop the element from the palette is pretty hard to hit. The line itself has a width of 1px. Below the transition the drag area starts exactly where the line starts, so it's hard to hit it from below. Above the transition it's a bit easier because there is a small area of probably 16px. Which is nice because from this side it's much easier to hit the transition. The worst case is a vertical transition because on the sides left and right there is no extended drop area which makes it very hard to hit the transition.
    My question is where I can influence this behaviour. I want to improve the user experience for the drag&drop and so I want to extend the drop area for the transition. Is this possible in GEF? If yes, where do I have to look? For a transition it seems to be harder than for an element that has a fixed size.
    Cheers, David

    sar_lax,
    Have you done any research at all? Even tried to find code examples other than posting here? Try this:
    1) go to www.google.com
    2) enter search words "java drag and drop"
    --A                                                                                                                                                                                                                                                                                                                                                                                           

  • How to implement drag-and-drop functionality in xMII iGrid?

    Hi,
    Is it possible to implement the drag and drop functionality between two iGrids of xMII in an irpt page? If yes can anyone please explain how?
    Thanks in advance,
    Dipankar

    http://tool-man.org/examples/sorting.html
    You would have to be creative and do something like this.

  • How can I drag & drop / copy & paste COPY Calendar event on iPad iOS6?

    How can I copy Calendar events on the iPad iOS 6?
    I have read various forums on this subject and have not found an answer on how to perform this basic function.
    To be clear, I am NOT asking how to drag & drop MOVE an event, rather how to duplicate an event.
    In this way, I would not have to create a new event on a different date that is very similar to an existing one.
    If I have missed this in the manual just tell me where it is discussed and I will check it again.
    Thank you!

    Hi,
    I don't think it is possible to do that in iOS 5.
    Best wishes
    John M

  • How do I drag / drop larger .psd or .jpg to Adobe Illustrator?

    I am trying to use Adobe Illustrator to create 1-page advertisements for magazine publications.  These advertisements have text, pictures and my business logo.  Unfortunately, I can not drag my logo from Photoshop Elements (nor Photoshop) to Adobe Illustrator.  The .psd of the logo file is 4 MB in size and a .jpg of the logo file is 700 in size.   I have no problem dragging small pictures that are ~150K in size. 
    Can someone please advise how to place the logo onto my Adobe Illustrator work space?  
    Is there a way to import the larger .psd or .jpg logo file directly into Adobe Illustrator?
    Is there a better Adobe application to use for these ads?   (From a learning curve, I am comfortable with Illustrator and DreamWeaver and still learning Photoshop.)
    My applications:  Adobe CS3 Suite for web publishing as well as Adobe Photoshop, Adobe Photoshop Elements, Premiere Elements and Adobe Illustrator
    My system:  8 GB Ram, MS Vista
    Please help.   Thanks.

    That works if all the data is available as a file at the point where you start the drag.
    In my case it is not, I have got to go get it from the database, and that can take up to 30 seconds.
    So I want to do that bit when the drop happens (which users are used to as for instance when they copy a large file in Windows at the moment), not when the drag starts (which is very difficult to provide any visual feedback for).

  • DPS - Web Content Overlay. How to implement dragging action in .folio?

    Hi there
    I am building a huge project, some kind of encyclopaedia with multimedia and interactive content I created using both Tumult Hype and Adobe Edge Animate 1.0. They are perfectly well loaded onto their own respective Web Content Overlay and work almost perfectly.
    One of them is a draggable game in which you drag a man towards one side or another just to see how it inclines. I have tried it in many browsers and it simply works perfectly well. But, when I bring it into the inDesign document (into a MSO) I can't drag the man, as the ACV changes the page.
    What can I do? Is there any way of avoiding this default behaviour when using these interactive content?
    Best regards,
    Luis Santa-Maria

    Ok, thanks for not answering anyway.
    I have managed to get the solution by myself. I just put a e.preventDefault(); function when dragging, and it just worked.
    Thanks again to all those who didn't help and knew how to do it.
    Best regards

  • How to implement drag&move JLable?

    hi,
    I am new to swing and pardon me if I ask some real simple questions.
    Using swing, i want to be able to drag&move components (like JLable/JTextField)
    in my content pane and then get components' precise postions (in X, Y coordinates, or
    something like that). It is like moving puzzle pieces around.
    PLS note: I want to MOVE the WHOLE component, NOT only the text within the component.
    Does swing support this internally? How can I do that? Any comments/suggestions/sample code
    are truly welcome.
    Thanks a lot.
    JK

    Do the way like DnD text for Label, except you put the entire JLabel component as Transferable data object.
    - The DropTarget will get the component and add it to "parent" ( "parent" is the container component that you like add the draged JLabel component)
    - The DragSource will get the endDrop notification and call its "parent" to delete the JLabel component dragged.
    You must deal with the "parent" container to add/delete the component for this special DnD component.
    There are no default Swing DnD support for it.

  • Drag&drop on dock icon (Cocoa)

    Hi!
    I started to learn cocoa with python and write small application.
    I start implementing drag & drop on NSView and it's cool and clear. But I don't understand how to implement drag & drop on dock icon. I tried to implement NSDraggingDestination protocol in application delegate, but it doesn't work.
    PS. Application written in PyObjC, but it doesn't matter.
    Thanks for advice.

    If I understand you correctly you want to open your app to having files dropped on it from Finder? You don't actually have to code for at all - Finder does all the work for you.
    In Xcode go to your Project window, click the Targets tab, expand the Targets element, highlight your build product (your App bundle) and hit the Info button.
    At the bottom is a list of Document types. This is where you set the document types that your Application will deal with - include custom suffix types that you want to "own" and documents your program wants to handle. You can also register for the types of pasteboards your application will accept when you copy/paste into it from another application.
    For good examples check out Sketch and TextEdit in the Examples > AppKit folder and see how those programs are registered for documents.
    It's been a while but as I recall this should all you need to do for alert the system that your application deal with that document type. This should cover both accepting dropped documents (notice how some apps accept certain types of dragged documents and others don't) and register you on the list when the Finder does "Open With..." listing of available applications.
    HTH,
    =Tod

  • Drag&Drop - how to change cursor?

    Hi,
    I know how to use Drag&Drop but I have two problems:
    1. I would like to have my icon displayed right next to the system's default cursor during dnd operation instead of displaying my icon only. How can I achieve this?
    2. when I use my own image as cursor during dnd operation, the size of the cursor is incorrect. It's supposed to have 24x24 pixels but it gets displayed in a different size. The ImageIcon still has 24x24 pixels, but the cursor is wrong.
    Thanks a lot!
    Regards,
    Ren�
    ImageIcon copyIcon = new ImageIcon("c:\\tmp\\drag_copy.gif");
    System.err.println(copyIcon.getIconWidth() + "; " + copyIcon.getIconHeight());
    copyCursor = Toolkit.getDefaultToolkit().createCustomCursor(
    copyIcon.getImage(), new java.awt.Point(0, 0), "I30COPY");
    e.startDrag(copyCursor, new StringSelection("DRAGITEM"), this);

    I just found a solution right here:
    http://www.javaworld.com/javaworld/javatips/jw-javatip114.html

  • How i can do a drag drop between container (grid)?

    I am trying to work out a task with Drag and Drop(WPF ,C#)to include in a demo ,i will explain easy showing an example of code in XAML 
    <Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
    <RowDefinition Height="*"/>
    <RowDefinition Height="*"/>
    <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid x:Name="container1" Grid.Row="0" >
    <Grid Name="grid1" Background="Aqua" Margin="15"></Grid>
    </Grid>
    <Grid x:Name="container2" Grid.Row="1" >
    <Grid Name="grid2" Background="blue" Margin="15"></Grid>
    </Grid>
    <Grid x:Name="container3" Grid.Row="2" >
    <Grid Name="grid3" Background="green" Margin="15"></Grid>
    </Grid>
    </Grid>
    My purpose is when the user drag the
    grid1 in the
    container2 automatically the grid2 will go to place in the
    container1 (basically I want to swap the grids) then this process will be used every time need to drag a grid in a container. with a code that i wrote down i can do a simple drag&drop  i can drag the "grid1"
    to the "container2" but cannot send back automatically the grid2 to container1.
    Kindly i ask if you have any advise or tips to make successful this task.
    Thank you so much for your attention
    Cheers!!!
    *********EDIT*********                                                                  
                                     Using this code as follow i can do the drag&drop but what really i need is the grid "container "is fix and never move just the
    "grid" should move between the "container "                                 
    <StackPanel Name="sp" AllowDrop="True" Background="SkyBlue" PreviewMouseLeftButtonDown="sp_PreviewMouseLeftButtonDown" PreviewMouseLeftButtonUp="sp_PreviewMouseLeftButtonUp" PreviewMouseMove="sp_PreviewMouseMove"
    DragEnter="sp_DragEnter" Drop="sp_Drop">
    <Grid Name="grid1" Background="Aqua" Height="120" Width="500"></Grid>
    <Grid Name="grid2" Background="Blue" Height="120" Width="500"></Grid>
    <Grid Name="grid3" Background="Red" Height="120" Width="500"></Grid>
    </StackPanel>
    private bool _isDown;
    private bool _isDragging;
    private Point _startPoint;
    private UIElement _realDragSource;
    private UIElement _dummyDragSource = new UIElement();
    public MainWindow()
    InitializeComponent();
    private void sp_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    if (e.Source == this.sp)
    else
    _isDown = true;
    _startPoint = e.GetPosition(this.sp);
    private void sp_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    _isDown = false;
    _isDragging = false;
    _realDragSource.ReleaseMouseCapture();
    private void sp_PreviewMouseMove(object sender, MouseEventArgs e)
    if (_isDown)
    if ((_isDragging == false) && ((Math.Abs(e.GetPosition(this.sp).X - _startPoint.X) > SystemParameters.MinimumHorizontalDragDistance) ||
    (Math.Abs(e.GetPosition(this.sp).Y - _startPoint.Y) > SystemParameters.MinimumVerticalDragDistance)))
    _isDragging = true;
    _realDragSource = e.Source as UIElement;
    _realDragSource.CaptureMouse();
    DragDrop.DoDragDrop(_dummyDragSource, new DataObject("UIElement", e.Source, true), DragDropEffects.Move);
    private void sp_DragEnter(object sender, DragEventArgs e)
    if (e.Data.GetDataPresent("UIElement"))
    e.Effects = DragDropEffects.Move;
    private void sp_Drop(object sender, DragEventArgs e)
    if (e.Data.GetDataPresent("UIElement"))
    UIElement droptarget = e.Source as UIElement;
    int droptargetIndex=-1, i =0;
    foreach (UIElement element in this.sp.Children)
    if (element.Equals(droptarget))
    droptargetIndex = i;
    break;
    i++;
    if (droptargetIndex != -1)
    this.sp.Children.Remove(_realDragSource);
    this.sp.Children.Insert(droptargetIndex, _realDragSource);
    _isDown = false;
    _isDragging = false;
    _realDragSource.ReleaseMouseCapture();
    Thanks :)

    Hello Jonny,
    Currently I do not have a sample and I have reviewed this post and find another way which seems more reasonable. Have you cosidered use a ListView instead of common grid. It seems we can do what you want with two common grid however we need to hardcoded
    all the things.
    If we use ListView, for example, you can see this thread:
    http://stackoverflow.com/questions/20573063/creating-icon-view-mode-for-listview-wpf
    and this thread:
    http://stackoverflow.com/questions/9443695/how-do-i-drag-drop-items-in-the-same-listview
    We can drag and drop items instead of grid, which will make this programming much easier than hard code to switch your control's location.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.
    Dear Barry Wang thank you so much for your kind support ,just open me a way to do it ,you can see in this post https://social.msdn.microsoft.com/Forums/vstudio/en-US/55873851-e86c-4a20-9b00-de3419054ba8/get-stuck-to-dragdrop-in-this-case?forum=wpf .
    Wish you a Happy New Year .
    Sincerley

  • Drag & Drop Links

    Hey,
    could someone help me to find an example or a tutorial how to code Drag & Drop for Files?
    In my demo I'd like to get the file path of a dragged object (e.g. a folder or a file from somewhere on the desktop or from the explorer..). All I could find so far was drag and drop for labels, texts etc, displayed in the same program somewhere.
    I know that the file thing should be possible, too, but can't find usefull information on that, like articles or how tos or any kind of links. TIA

    As I overflew it briefly, it seems that it's only
    possible if the "File" to drag is already contained
    in a Java JFrame like window - is there no way to
    simply drag a file from somewhere on the desktop or
    the explorer on to the Java application (I know, it
    seems to be hardly possible to provide functionality
    like this and to stay system independant, but is
    there a way)?There must be - I meant this is exactly what I did. But it was long ago... I remember it wasn't very complicated to implement, but I don't remember how I did it. Sorry.

Maybe you are looking for

  • How do I get rid of a search engine that has taken over home page?

    Search.US.com has taken over my hone page and everything else it can. I have tried all the suggestions available to me by the help section. I have went so far as to delete cookies. This is very invasive. I looked at restoring the system but have few

  • Macbook Pros and IT depts

    Hello- I have to buy a Macbook Pro for my son's new school in Shanghai. I was told that he can only use the 13 inch model. When asked why he can't use a 15 inch, I was told that the 13 and 15 inch models have "different internals" (video card, networ

  • Rotating video 180 degrees?

    I have a special need to be able to rotate certain clips within a video 180 degrees.  I am mounting a small video camcorder in a mid-power model rocket and will be launching the camcorder to an altitude of approximately 5000'.  During the ascent (Pha

  • Deauthorizing computer?

    im having the whole itunes not opening up error message gig, and i have another computer i decided to use and itunes works, but i cant deauthorize the computer that doesnt! it has all my music and videos on it but i cant get them on my other itunes b

  • Text Remarks ofLength greater than 60

    Hi  Everyone,                   I have a requirement where  I need to pull a field called Remarks from ECC System and it is a Long Text. As , it is , Long Text will not be stored in a Table. So , there is a R/3 Function Module using which we can get