Drag and Drop Swing Components between two different Application Windows

Hi!!!
I tried the Dnd feature using the DnD api. It was a simple test, where I ahd two different app windows each made up of a JLabel. One I registered as drag component and the other as a drop component. the drop componenet(JLabel) does not have any text making it invisble to the eyes. When I drag the other JLabel to the drop window, the drop JLAbel takes the text value. I was successful so far.
But can I do the same for any other Swing component in a scenario where when I drag the component, the component should have physically moved into the other window.
any help on this with sample code will be greatly apprciated.
Thanks in advance
Suja

Ok I found the answer to your problem. If you download the tutorial they have the code there it's in one folder. I hope this helps.
http://java.sun.com/docs/books/tutorial/

Similar Messages

  • How to drag and drop an Image between two JPanels inside a Split Pane

    I'm tring to do that, and my actual problem is as follows:
    I drag the Image from the bottomPanel but I can't drop it in the topPanel, I'm using this classes:
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    import java.awt.image.*;
    public class MoveableComponentsContainer extends JSplitPane {     
         public DragSource dragSource;
         public DropTarget dropTarget;
    public JPanel topPanel = new JPanel();
    public JPanel bottomPanel = new JPanel();
         public int ancho;
    public int alto;
    public MoveableLabel lab1,lab2,lab3,lab4;
    public Icon ico1, ico2,ico3,ico4;
    private static BufferedImage buffImage = null; //buff image
         private static Point cursorPoint = new Point();
    public int getMaximumDividerLocation() {
    return ( ( int ) ( alto * .85 ) );
    public int getMinimumDividerLocation() {
    return( ( int ) ( alto * .85 ) );
         public MoveableComponentsContainer(int Weight, int Height ) {
    alto = Height;
    ancho = Weight;
    setOrientation( VERTICAL_SPLIT);
    setDividerSize(2);
    getMaximumDividerLocation();
    getMinimumDividerLocation();
    setPreferredSize(new Dimension( (int) ( Weight * .99 ), (int) ( Height * .94 ) ) );
    setDividerLocation( getMaximumDividerLocation() );
    System.out.println( " getDividerLocation() = " + getDividerLocation() );
    topPanel.setName("topPanel");
    bottomPanel.setName("bottomPanel");
    bottomPanel.setPreferredSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .15 ) ) );
    bottomPanel.setMaximumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .15 ) ) );
    bottomPanel.setMinimumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .15 ) ) );
    topPanel. setPreferredSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .85 ) ) );
    topPanel. setMaximumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .85 ) ) );
    topPanel. setMinimumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .85 ) ) );
    bottomPanel.setEnabled(true);
    bottomPanel.setVisible(true);
    bottomPanel.setBackground( new Color( 57,76,123 ) );
    topPanel. setEnabled(true);
    topPanel. setVisible(true);
    topPanel. setBackground( new Color( 57,76,123 ) );
    setBottomComponent( bottomPanel );
    setTopComponent( topPanel );
    setOneTouchExpandable( false );
    bottomPanel.setBorder(BorderFactory.createTitledBorder("Drag and Drop Test"));
              setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white, Color.gray));
    bottomPanel.setLayout( new FlowLayout() );
    topPanel.setLayout(new FlowLayout());
              addMoveableComponents();
         private void addMoveableComponents() {
    ico1 = new ImageIcon( "/usr/local/installers/java/lll/DnD/switchm.gif");
    lab1 = new MoveableLabel("Centrales", ico1, topPanel );
    lab1.setName("labelOne");
    bottomPanel.add( lab1 );
              lab2 = new MoveableLabel("Destinos", ico1, topPanel);
    lab2.setName("labelTwo");
              bottomPanel.add( lab2 );
              lab3 = new MoveableLabel("Registros", ico1, topPanel );
    lab3.setName("labelThree");
              bottomPanel.add( lab3 );
              lab4 = new MoveableLabel("Parametros", ico1, topPanel);
    lab4.setName("labelFour");
              bottomPanel.add( lab4 );
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    public class MoveableLabel extends JLabel implements Transferable {
    final static int FILE = 0;
    final static int STRING = 1;
    final static int IMAGE = 2;
    DataFlavor flavors[] = { DataFlavor.javaFileListFlavor,
    DataFlavor.stringFlavor,
    DataFlavor.imageFlavor };
    public JPanel PanelDestino;
    public JPanel PanelOrigen;
    public DropTarget dropTarget;
    public DropTargetListener dropTargetLis;
         private static final Border border = BorderFactory.createLineBorder(Color.black, 1);
         public MoveableLabel(String text, Icon ic, JPanel DestPanel) {
              super( text, ic, TRAILING);
    PanelDestino = DestPanel;
              MouseEventForwarder forwarder = new MouseEventForwarder();
              addMouseListener(forwarder);
              addMouseMotionListener(forwarder);
              setBorder(border);
              setBounds(0,0,50,100);
              setOpaque(true);
    setTransferHandler(new TransferHandler("text"));
    setBackground( new Color( 57,76,123 ) );
    public synchronized DataFlavor[] getTransferDataFlavors() {
         return flavors;
    public boolean isDataFlavorSupported(DataFlavor flavor) {
    boolean b = false;
    b |= flavor.equals(flavors[ FILE ]);
    b |= flavor.equals(flavors[STRING]);
    b |= flavor.equals(flavors[ IMAGE]);
    return (b);
    public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, java.io.IOException {
    return this;
         final class MouseEventForwarder extends MouseInputAdapter {
              public void mousePressed(MouseEvent e) {
                   Container parent = getParent();
    Container brother = (Container)PanelDestino;
    System.out.println( "Parent 1 = " + parent.getName() );
    System.out.println( "Destino 1 = " + brother.getName() );
    JComponent c = (JComponent) e.getSource();
    System.out.println( "getsource() = " + c.getName() );
    TransferHandler th = c.getTransferHandler();
    th.exportAsDrag( c, e, TransferHandler.COPY_OR_MOVE );
    dropTarget = getDropTarget();
    System.out.println( "dropTarget.getComponent().getName() = " + dropTarget.getComponent().getName() );
    for ( int a=0; a < parent.getComponentCount(); a++ ) {
    parent.getComponent( a ).setEnabled( false );
    brother.setDropTarget( dropTarget );
    System.out.println( "dropTarget.getComponent().getName() = " + dropTarget.getComponent().getName() );
              public void mouseReleased(MouseEvent e) {
                   Container parent = getParent();
    Container brother = PanelDestino;
    System.out.println( "Parent 2 = " + parent.getName() );
    System.out.println( "Destino 2 = " + PanelDestino.getName() );
    parent.setEnabled( true );
    brother.setEnabled( false );
    for ( int a=0; a < parent.getComponentCount(); a++ ) {
    parent.getComponent( a ).setEnabled( true );
    import java.awt.*;
    import javax.swing.*;
    public class TestDragComponent extends JFrame {
         public TestDragComponent() {
    super("TestDragComponent");
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension dm = new Dimension();
    dm = tk.getScreenSize();
    System.out.println(dm.height);
    System.out.println(dm.width );
    Container cntn = getContentPane();
    cntn.setFont(new Font("Helvetica", Font.PLAIN, 14));
    cntn.add(new MoveableComponentsContainer(dm.width,dm.height));
              pack();
              setVisible(true);
         public static void main(String[] args) {
              new TestDragComponent();

    Ok I found the answer to your problem. If you download the tutorial they have the code there it's in one folder. I hope this helps.
    http://java.sun.com/docs/books/tutorial/

  • How to drag and drop tab nodes between tab panes

    I'm working on example from this tutorial( Drag-and-Drop Feature in JavaFX Applications | JavaFX 2 Tutorials and Documentation ). Based on the tutorial I want to drag tabs between two tabs. So far I managed to create this code but I need some help in order to finish the code.
    Source
    tabPane = new TabPane();
    Tab tabA = new Tab();
       Label tabALabel = new Label("Main Component");
    tabPane.setOnDragDetected(new EventHandler<MouseEvent>()
                @Override
                public void handle(MouseEvent event)
                    /* drag was detected, start drag-and-drop gesture*/
                    System.out.println("onDragDetected");
                    /* allow any transfer mode */
                    Dragboard db = tabPane.startDragAndDrop(TransferMode.ANY);
                    /* put a string on dragboard */
                    ClipboardContent content = new ClipboardContent();
                    content.put(DataFormat.PLAIN_TEXT, tabPane);
                    db.setContent(content);
                    event.consume();
    What is the proper way to insert the content of the tab as object? Into the tutorial simple text is transferred. How I must modify this line content.put(DataFormat.PLAIN_TEXT, tabPane);?
    And what is the proper way to insert the tab after I drag the tab:
    Destination
    tabPane.setOnDragDropped(new EventHandler<DragEvent>()
                @Override
                public void handle(DragEvent event)
                    /* data dropped */
                    /* if there is a string data on dragboard, read it and use it */
                    Dragboard db = event.getDragboard();
                    boolean success = false;
                    if (db.hasString())
                        //tabPane.setText(db.getString());
                        Tab tabC = new Tab();
                        tabPane.getTabs().add(tabC);
                        success = true;
                    /* let the source know whether the string was successfully
                     * transferred and used */
                    event.setDropCompleted(success);
                    event.consume();
    I suppose that this transfer can be accomplished?
    Ref javafx 2 - How to drag and drop tab nodes between tab panes - Stack Overflow

    I would use a graphic (instead of text) for the Tabs and call setOnDragDetected on that graphic. That way you know which tab is being dragged. There's no nice way to put the Tab itself into the dragboard as it's not serializable (see https://javafx-jira.kenai.com/browse/RT-29082), so you probably just want to store the tab currently being dragged in a property.
    Here's a quick example; it just adds the tab to the end of the current tabs in the dropped pane. If you wanted to insert it into the nearest location to the actual drop you could probably iterate through the tabs and figure the coordinates of each tab's graphic, or something.
    import java.util.Random;
    import javafx.application.Application;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.control.Tab;
    import javafx.scene.control.TabPane;
    import javafx.scene.input.ClipboardContent;
    import javafx.scene.input.DragEvent;
    import javafx.scene.input.Dragboard;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.input.TransferMode;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class DraggingTabPane extends Application {
      private static final String TAB_DRAG_KEY = "tab" ;
      private ObjectProperty<Tab> draggingTab ;
    @Override
      public void start(Stage primaryStage) {
      draggingTab = new SimpleObjectProperty<>();
      TabPane tabPane1 = createTabPane();
      TabPane tabPane2 = createTabPane();
      VBox root = new VBox(10);
      root.getChildren().addAll(tabPane1, tabPane2);
      final Random rng = new Random();
      for (int i=1; i<=8; i++) {
        final Tab tab = createTab("Tab "+i);
        final StackPane pane = new StackPane();
          int red = rng.nextInt(256);
          int green = rng.nextInt(256);
          int blue = rng.nextInt(256);
        String style = String.format("-fx-background-color: rgb(%d, %d, %d);", red, green, blue);
        pane.setStyle(style);
        final Label label = new Label("This is tab "+i);
        label.setStyle(String.format("-fx-text-fill: rgb(%d, %d, %d);", 256-red, 256-green, 256-blue));
        pane.getChildren().add(label);
        pane.setMinWidth(600);
        pane.setMinHeight(250);
        tab.setContent(pane);
        if (i<=4) {
          tabPane1.getTabs().add(tab);
        } else {
          tabPane2.getTabs().add(tab);
      primaryStage.setScene(new Scene(root, 600, 600));
      primaryStage.show();
      public static void main(String[] args) {
      launch(args);
      private TabPane createTabPane() {
        final TabPane tabPane = new TabPane();
        tabPane.setOnDragOver(new EventHandler<DragEvent>() {
          @Override
          public void handle(DragEvent event) {
            final Dragboard dragboard = event.getDragboard();
            if (dragboard.hasString()
                && TAB_DRAG_KEY.equals(dragboard.getString())
                && draggingTab.get() != null
                && draggingTab.get().getTabPane() != tabPane) {
              event.acceptTransferModes(TransferMode.MOVE);
              event.consume();
        tabPane.setOnDragDropped(new EventHandler<DragEvent>() {
          @Override
          public void handle(DragEvent event) {
            final Dragboard dragboard = event.getDragboard();
            if (dragboard.hasString()
                && TAB_DRAG_KEY.equals(dragboard.getString())
                && draggingTab.get() != null
                && draggingTab.get().getTabPane() != tabPane) {
              final Tab tab = draggingTab.get();
              tab.getTabPane().getTabs().remove(tab);
              tabPane.getTabs().add(tab);
              event.setDropCompleted(true);
              draggingTab.set(null);
              event.consume();
        return tabPane ;
      private Tab createTab(String text) {
        final Tab tab = new Tab();
        final Label label = new Label(text);
        tab.setGraphic(label);
        label.setOnDragDetected(new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            Dragboard dragboard = label.startDragAndDrop(TransferMode.MOVE);
            ClipboardContent clipboardContent = new ClipboardContent();
            clipboardContent.putString(TAB_DRAG_KEY);
            dragboard.setContent(clipboardContent);
            draggingTab.set(tab);
            event.consume();
        return tab ;

  • Pls Help! Drag and Drop problem, identical symbols acting differently - same code! WHY?

    In the attached file, I have a series of symbols that have a drag and drop command to change colour at different sections of a bullseye, and that are also text editable (html).
    However, some of the symbols get stuck and will not be moved after moving once or at all, and some get stuck once their text has been edited.
    I have poured over the code and it appears to be the same for each symbol - can anyone explain as to why this is happening?
    I also cannot now edit the text properly on the ipad (it is really fiddly to change between different symbols to edit their text -- is there maybe a better way to do this? A button to change between symbols to then edit their text, can you help with this too?)
    THANK YOU SO MUCH!!!
    File here:
    https://www.dropbox.com/s/g71gnfichjgyehn/NEW%20RISK%20RADAR.zip

    Hi, I think I undertsand what you mean now, so the code is as below, btu I am not sure what a handler is? but some of my risks still get stuck once the text has been changed on them:
    // Use for loop for attr
    // deleted  yepnope since you load with scropt loading
    // added pos for each symbol so we can replace them there.
    document.ontouchmove = function(e) {
            e.preventDefault();
    var risk = ;
    var Pos = [
    {'x':-9,'y':806},
    {'x':27,'y':854},
    {'x':72,'y':894},
    {'x':71,'y':934},
    {'x':231,'y':811},
    {'x':231,'y':853},
    {'x':231,'y':894},
    {'x':231,'y':934},
    {'x':388,'y':811},
    {'x':388,'y':852},
    {'x':388,'y':893},
    {'x':388,'y':934},
    {'x':543,'y':811},
    {'x':543,'y':853},
    {'x':543,'y':893},
    {'x':543,'y':934}
    var myText = ; 
    for (i=0;i<risk.length;i++){
    sym.getSymbol(risk[i]).$(risk[i]).attr("contenteditable",true);
    sym.$('Quadrant_text').attr("contenteditable",true);
    sym.$('Quadrant1_text').attr("contenteditable",true);
    sym.$('Quadrant2_text').attr("contenteditable",true);
    sym.$('Quadrant3_text').attr("contenteditable",true);
    // apply the draggable JQuery UI plugin to the MyDraggableSymbol symbol on your stage
    sym.$('Risk1').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk1").stop("Initial");
      sym.setVariable("symName","Risk1");
    //adding for risk3_orange similarly add for other symbols
    sym.$('Risk1').draggable();
    sym.getSymbol('Risk1').$("Risk1").bind('click tap',function(ev) {
         sym.$('Risk1').draggable('disable');
    }).unbind('dblclick tap',function(ev) {
         sym.$('Risk1').draggable('enable');
    sym.$('Risk2').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk2").stop("Initial");
      sym.setVariable("symName","Risk2");
    //adding for Risk2 similarly add for other symbols
    sym.$('Risk2').draggable();
    sym.getSymbol('Risk2').$("Risk2").bind('click tap',function(ev) {
         sym.$('Risk2').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk2').draggable('enable');
    sym.$('Risk3').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk3").stop("Initial");
      sym.setVariable("symName","Risk3");
    //adding for Risk3 similarly add for other symbols
    sym.$('Risk3').draggable();
    sym.getSymbol('Risk3').$("Risk3").bind('click tap',function(ev) {
         sym.$('Risk3').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk3').draggable('enable');
    sym.$('Risk4').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk4").stop("Initial");
      sym.setVariable("symName","Risk4");
    //adding for Risk4 similarly add for other symbols
    sym.$('Risk4').draggable();
    sym.getSymbol('Risk4').$("Risk4").bind('click tap',function(ev) {
         sym.$('Risk4').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk4').draggable('enable');
    sym.$('Risk5').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk5").stop("Initial");
      sym.setVariable("symName","Risk5");
    //adding for Risk5 similarly add for other symbols
    sym.$('Risk5').draggable();
    sym.getSymbol('Risk5').$("Risk5").bind('click tap',function(ev) {
         sym.$('Risk5').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk5').draggable('enable');
    sym.$('Risk6').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk6").stop("Initial");
      sym.setVariable("symName","Risk6");
    //adding for Risk6 similarly add for other symbols
    sym.$('Risk6').draggable();
    sym.getSymbol('Risk6').$("Risk6").bind('click tap',function(ev) {
         sym.$('Risk6').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk6').draggable('enable');
    sym.$('Risk7').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk7").stop("Initial");
      sym.setVariable("symName","Risk7");
    //adding for Risk7 similarly add for other symbols
    sym.$('Risk7').draggable();
    sym.getSymbol('Risk7').$("Risk7").bind('click tap',function(ev) {
         sym.$('Risk7').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk7').draggable('enable');
    sym.$('Risk8').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk8").stop("Initial");
      sym.setVariable("symName","Risk8");
    //adding for Risk8 similarly add for other symbols
    sym.$('Risk8').draggable();
    sym.getSymbol('Risk8').$("Risk8").bind('click tap',function(ev) {
         sym.$('Risk8').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk8').draggable('enable');
    sym.$('Risk9').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk9").stop("Initial");
      sym.setVariable("symName","Risk9");
    //adding for Risk9 similarly add for other symbols
    sym.$('Risk9').draggable();
    sym.getSymbol('Risk9').$("Risk9").bind('click tap',function(ev) {
         sym.$('Risk9').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk9').draggable('enable');
    sym.$('Risk10').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk10").stop("Initial");
      sym.setVariable("symName","Risk10");
    //adding for Risk10 similarly add for other symbols
    sym.$('Risk10').draggable();
    sym.getSymbol('Risk10').$("Risk10").bind('click tap',function(ev) {
         sym.$('Risk10').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk10').draggable('enable');
    sym.$('Risk11').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk11").stop("Initial");
      sym.setVariable("symName","Risk11");
    //adding for Risk11 similarly add for other symbols
    sym.$('Risk11').draggable();
    sym.getSymbol('Risk11').$("Risk11").bind('click tap',function(ev) {
         sym.$('Risk11').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk11').draggable('enable');
    sym.$('Risk12').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk12").stop("Initial");
      sym.setVariable("symName","Risk12");
    //adding for Risk12 similarly add for other symbols
    sym.$('Risk12').draggable();
    sym.getSymbol('Risk12').$("Risk12").bind('click tap',function(ev) {
         sym.$('Risk12').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk12').draggable('enable');
    sym.$('Risk13').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk13").stop("Initial");
      sym.setVariable("symName","Risk13");
    //adding for Risk13 similarly add for other symbols
    sym.$('Risk13').draggable();
    sym.getSymbol('Risk13').$("Risk13").bind('click tap',function(ev) {
         sym.$('Risk13').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk13').draggable('enable');
    sym.$('Risk14').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk14").stop("Initial");
      sym.setVariable("symName","Risk14");
    //adding for Risk14 similarly add for other symbols
    sym.$('Risk14').draggable();
    sym.getSymbol('Risk14').$("Risk14").bind('click tap',function(ev) {
         sym.$('Risk14').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk14').draggable('enable');
    sym.$('Risk15').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk15").stop("Initial");
      sym.setVariable("symName","Risk15");
    //adding for Risk15 similarly add for other symbols
    sym.$('Risk15').draggable();
    sym.getSymbol('Risk15').$("Risk15").bind('click tap',function(ev) {
         sym.$('Risk15').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk15').draggable('enable');
    sym.$('Risk16').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk16").stop("Initial");
      sym.setVariable("symName","Risk16");
    //adding for Risk16 similarly add for other symbols
    sym.$('Risk16').draggable();
    sym.getSymbol('Risk16').$("Risk16").bind('click tap',function(ev) {
         sym.$('Risk16').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk16').draggable('enable');
    sym.getSymbol("Drop").$('Outer').droppable(
    sym.getSymbol("Drop").$('Middle').droppable(
    sym.getSymbol("Drop").$('Target').droppable(
    sym.$('resetBtn').click(function(){
      sym.$('Quadrant_text').html('Quadrant');
      sym.$('Quadrant1_text').html('Quadrant');
      sym.$('Quadrant2_text').html('Quadrant');
      sym.$('Quadrant3_text').html('Quadrant');
    for (i=0;i<risk.length;i++){
      sym.$(risk[i]).css({"left":Pos[i].x,"top":Pos[i].y,"position":"absolute"})
      sym.getSymbol(risk[i]).stop(0);
      sym.getSymbol(risk[i]).$(risk[i]).html("Challenge");
    But is still doesn't work,
    Subject: Re:  Pls Help! Drag and Drop problem, identical symbols acting differently - same code! WHY?

  • 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

  • Service Contract and Service Quote, Are they two different application or s

    Service Contract and Service Quote, Are they two different application or same application ?
    What is the difference ?
    thanks
    siva

    Siva
    There is no application called Service Quote (But we can have services in the quoting lines).
    Thanks
    Nagamohan

  • 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");

  • Drag and Drop game with only two targets

    I created a drag and drop activity where their are five boxes that are supposed to go in to two columns in any order. I found a tutorial online that I based this activity off of.
    The problem is that the tutorial shows you how to make a target for each mc which has worked for all the activities I've made except for this one where I need only two targets. How would I change it so I can have multiple mc's drop on to one target?
    This is my AS:
    var score:Number = 0;
    var objectoriginalX:Number;
    var objectoriginalY:Number;
    growing_mc.buttonMode = true;
    growing_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
    growing_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    gorging_mc.buttonMode = true;
    gorging_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
    gorging_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    dormancy_mc.buttonMode = true;
    dormancy_mc.addEventListener(MouseEvent.MOUSE_DOWN  , pickupObject);
    dormancy_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    cystform_mc.buttonMode = true;
    cystform_mc.addEventListener(MouseEvent.MOUSE_DOWN  , pickupObject);
    cystform_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    hosttrans_mc.buttonMode = true;
    hosttrans_mc.addEventListener(MouseEvent.MOUSE_DOW  N, pickupObject);
    hosttrans_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    function pickupObject(event:MouseEvent):void {
    event.target.startDrag(true);
    event.target.parent.addChild(event.target);
    objectoriginalX = event.target.x;
    objectoriginalY = event.target.y;
    function dropObject(event:MouseEvent):void {
    event.target.stopDrag();
    var matchingTargetName:String = "target" + event.target.name;
    var matchingTargetisplayObject = getChildByName(matchingTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == matchingTarget){
    event.target.removeEventListener(MouseEvent.MOUSE_  DOWN, pickupObject);
    event.target.removeEventListener(MouseEvent.MOUSE_  UP, dropObject);
    event.target.buttonMode = false;
    event.target.x = matchingTarget.x;
    event.target.y = matchingTarget.y;
    score++;
    scoreField.text = String(score);
    } else {
    event.target.x = objectoriginalX;
    event.target.y = objectoriginalY;
    if(score == 5){
    response_mc.gotoAndStop(2);

    var matchingTargetName:String =(event.target.name).substring(0, 1);
    Change the name of the target to A and B and the mc A1, A2, A3, A4... and B1, B2,B3...

  • Drag and drop no longer between shared libraries after updating to itunes 10.5.

    Used to be able to open up and drag and drop from one computer to another using home sharing. No longer works. Any ideas?

    same here except i have windows vista and its my new iphone 4s.  it freezes on the backing up phase.

  • Error using Richfaces Drag and Drop  support in JSF 1.1 application

    Iam using rich faces drag n drop support in my JSF application . The jsp works as expected but I get this weird exception while navigating through my pages.
    Scenario : User logs into the application , from the home page ---> when the user click on a button he is navigated to the jsp which has the drag n drop support. This was working fine till , I have added a menu_incl .jsp inthe sub view . The code snippet is as shown below :
    <body>
         <div id="wrap">
         <f:view>
         <f:subview id="menu">
              <jsp:include page="/search/incld/menu.incl.jsp" />
         </f:subview>
         <rich:dragIndicator id="indicator" />
         <h:form id="myfolder">
              <h:panelGrid columnClasses="panelc,panelc,panelc,panelc" columns="4" width="100%">
                   <!-- Panel for Queries -->     
                   <rich:panel style="width:133px">
                   <f:verbatim>
                             <div style="overflow-x: scroll; overflow-y: scroll; height: 400px;">
                   </f:verbatim>
                        <f:facet name="header">
                             <h:outputText value="Queries" />
                        </f:facet>
                        <h:dataTable id="querytable" value="#{dndBean.queryList}"
                             var="query" binding="#{workSpaceBean.queryData}" >
                             <h:column>
                                  <a4j:outputPanel style="width:100px;border:1px solid gray;padding:2px" layout="block">
                                       <rich:dragSupport dragIndicator=":indicator"
                                            dragType="Query" dragValue="#{query}">
                                            <rich:dndParam name="label" value="#{query.name}" />
                                       </rich:dragSupport>
                                       <h:commandLink value="#{query.name}"
                                       action="#{workSpaceBean.populateQuery}">
                                       </h:commandLink>
                                  </a4j:outputPanel>
                             </h:column>
                        </h:dataTable>
                        <f:verbatim></div> </f:verbatim>
                   </rich:panel>
    Now when I click on the button in my home page , and expect to be navigated to the page which has dran drop support components, I get the following error :
    Error Message: Duplicate component ID 'myfolder:querytable:_id34' found in view.
    Error Code: 500
    Target Servlet: Faces Servlet
    Error Stack:
    java.lang.IllegalStateException: Duplicate component ID 'myfolder:querytable:_id34' found in view.
    at com.sun.faces.application.StateManagerImpl.removeTransientChildrenAndFacets(StateManagerImpl.java:171)
    at com.sun.faces.application.StateManagerImpl.removeTransientChildrenAndFacets(StateManagerImpl.java:179)
    at com.sun.faces.application.StateManagerImpl.removeTransientChildrenAndFacets(StateManagerImpl.java:179)
    at com.sun.faces.application.StateManagerImpl.removeTransientChildrenAndFacets(StateManagerImpl.java:179)
    at com.sun.faces.application.StateManagerImpl.removeTransientChildrenAndFacets(StateManagerImpl.java:179)
    at com.sun.faces.application.StateManagerImpl.removeTransientChildrenAndFacets(StateManagerImpl.java:179)
    at com.sun.faces.application.StateManagerImpl.saveSerializedView(StateManagerImpl.java:86)
    at org.ajax4jsf.framework.ajax.AjaxStateManager.saveSerializedView(AjaxStateManager.java:90)
    at com.sun.faces.taglib.jsf_core.ViewTag.doAfterBody(ViewTag.java:170)
    Iam getting this error only when I include this jsp in the parent jsp :
    <f:subview id="menu">
              <jsp:include page="/search/incld/menu.incl.jsp" />
    </f:subview>
    Iam including the same way in all other jsps of my application , they are all working fine expect for this jsp which has ajax components (rich faces drag m drop support components ) .
    From the error I deduce that the view component is being generated twice , why is this so???
    I would appreciate if some one coulkd guide me through this .... I hope I was able to explain my issu properly , please let me know if it is now clear

    I've tinkered a bit with DnD before in the past. Actually, it's all related to the topic of Data Transfer. You have to provide a source and destination for the transferrable, and your transferrable object must provide the "data flavors" that it supports.
    In theory it doesn't sound too hard, and it works reasonably well within a java application, but to be honest your time might be better spent simply implementing cut n' paste, which is easier. Cut n' paste doesn't require all the fancy UI work, but does the job reasonably well.
    There's a DnD spec available on the documentation web-site, if you haven't already found it. I also discovered that the O'Reilly book (I think it's the AWT book, not the swing one) has a good chapter on data transfer that you might want to read.

  • Drag and drop file into Outlook from AIR application

    I am hoping to see if this would be possible with the Adobe AIR API. We currently have a desktop AIR application that clients install in order to facilitate certain operations triggered via a web application (such as opening files directly from the web).
    One of the actions we are requested to support is the ability to drag and drop files from our web application directly into Outlook and have the file added as an attachment. I saw the documentation at Adobe Flash Platform * Dropping file promises and was wondering if this might be a possibility, or if there was some other method of performing this.
    We are trying to get around the fact that users now have to download a document to their desktop before being able to attach in Outlook.
    Thanks for any assistance.

    You just aren't calling the right NativeDragManager functions. See http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7d83.html

  • Drag and Drop isn't working on iTunes in Windows 8.1

    I did a clean install of 8.1; drivers for all devices up to date.  I cannot use the drag and drop feature in iTunes (for example, to add songs to a playlist).  Can anyone offer a solution?  Do I  have to have Quicktime or Java installed in addition to iTunes?

    In iTunes on your computer, choose File > Add to Library and select the PDF. Then sync. See iTunes Help for more info about syncing

  • Can My Dad and I Swap iPhones between two different accounts???

    Last week I purchased an iPhone 3g. Now I find out the 3gs is available. My dad saw my 3g and is going to purchase one when he switches from Verizon in August.
    I want the 3gs.
    He wants the 3g.
    Here is what we want to do. He wants to purchase the 3gs and swap it with my 3g. Is this possible? If so, what do I need to do? These are two different accounts - its not a family plan.
    Thanks!
    Message was edited by: Hardsheller

    Thanks, I did just that. They said since I'm a premier customer that I had a 30 day buyers remorse policy and they allowed me to upgrade for the difference I paid for the 3G (16GB) and the 3G S (32 GB)!

  • Getting attributes from session between two different applications

    I'm developing with JDK 1.3 and deploying my webapp at ORACLE 9iAS.
    I would like to jump between JSPs deployed at differents OC4J instances and
    keep session object. I've seen I can get sessionID and it's the same but the attributes have disapeared.
    I jump using JavaScript code (document.location.href).
    Should I use a <form> ?
    Should I use getServletContext() method ?
    I dont know even if it's possible and I don't want to loose my time looking for a solution that doesn't exist.
    NEED HELP, AN EXAMPLE OR WHATEVER USEFUL.
    ... THE SOON AS POSSIBLE
    THANX in advance
    PS..- I have already look for in this forum but I didn't get any info to solve my doubts. If I mistaken please let me know

    Ok.
    getServletContext().getContext() may return null in 'security conscious' servers. Apparently this is your case, therefore you wouldn't be able to use it to store global data...
    As for sharing sessions directly between different web apps, the servlet spec (since 2.2 at least) explicitely prohibits it.
    The link provided by tolmank about pseudo-sessions should address your issue, since it will allow you to distribute your session data on your different webapps.
    Some other alternatives would be :
    -store the session data in the DB (slow)
    -use java serialization
    -use RMI
    -use JNDI
    -if you're using Tomcat, you can implement single-signon accross multiple apps using cookies :
    http://www.ingrid.org/jajakarta/tomcat/tomcat-4.0b5/src/catalina/docs/singlesignon.html

  • Is it possible to Drag and Drop from KDE into a Java application?

    Can someone please let me know if it is possible to drag a file, or any other object from KDE (linux) to a Java application? If so, could you give any code examples that could help supplement an explaination?

    http://java.sun.com/products/jfc/tsc/articles/dragndrop/index.html
    http://java.sun.com/j2se/1.4.2/docs/guide/dragndrop/index.html

Maybe you are looking for

  • How can I update a catalog on my laptop and then transfer the updates to master catalog on desktop?

    This is similar to Goeffbubbles question but I don't want to have the original files on both laptop and desktop Here is the question: I want to make a copy of a Lightroom 3 catalog to put on my laptop so while on the move I can be geo-tagging and key

  • Solution Manager 4.0 CRM 5.0 (TREX)

    Dear SDN This is my first time using SDN and I would like to ask you for help, please. This is urgent! We have Solution Manager 4.0 CRM 5.0 We would like to setup the Solution Database function in CRM Software Agent Framework. What version of TREX ca

  • Managing PDF's without Adobe Reader

    Now that I have a new MBP and 10.6 I'm without Adobe Reader and everything is going to "preview". How do I get long documents to open with a straight on view for every page instead of preview showing them side ways? I can get each single page to turn

  • Cant get picture on my tv

    hp dm4 says unable to start intel my wifi technology when i try to enable it just stays disabled and i had picture last time i used it on the tv

  • Shared Sever Mode and Total No of Connections  ?

    Hello, Env:Ora 10g on Win2003 The DB is in Shared Server Mode (yes, the application connects with SERVER=SHARED). During peak hour i could see around 80 connections in v$session from the this username with server = shared. The count of shared servers