• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

When doing Drag and Drop in Java 1.6 some of the Data in my Custom source class is not available in my ImportData method.

I am attempting to do Drag and Drop using Java 1.6.  I have written a class that extends TransferHandler.  I have a custom class that I am wrapping the Transferable around.  It has as a member variable another custom class that I can get using a getter method.  Some of the data from the custom class is not there in my importData method including the custom subclass when I call its getter method.  Can anyone tell me why some of the data associated with my source custom class is not available in my importData method?  I have looked at the links to the tutorials and they do not have examples that deal with this situation.

  • 2
1 Solution
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
Sorry to say this but the question is not very clear please provide the code snippets.

I think this has nothing to do with Drag drop as such it seems to be some scoping issue of the classes.
gdkinney_2Author Commented:
Actually I think I solved the problem of some data not getting to the importData method in the class that extends TransferHandler.  Some of the members in the class were transient and that kept them from being available in the importData method.  

I have another question though is it possible using the Drag and Drop APIs to have a source class for Drag and Drop that does not descend from JComponent.  The exportAsDrag method in the TransferHandler class that initiates the Drag procedure is as follows:       
exportAsDrag(JComponent comp, InputEvent e, int action)

so it could not be called to initate the drag when the source class does not descend from JComponent.  In that case when the source class does not descend from JComponent how would you initiate the Drag operation in 1.6 Drag and Drop?
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
I don't think there are any visual components which do not descend from JComponent.

All components in Swing like JLabel, JPanel all are Jcomponets

Class JComponent

  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent

All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable

Direct Known Subclasses:
AbstractButton, BasicInternalFrameTitlePane, Box, Box.Filler, JColorChooser, JComboBox, JFileChooser, JInternalFrame, JInternalFrame.JDesktopIcon, JLabel, JLayeredPane, JList, JMenuBar, JOptionPane, JPanel, JPopupMenu, JProgressBar, JRootPane, JScrollBar, JScrollPane, JSeparator, JSlider, JSpinner, JSplitPane, JTabbedPane, JTable, JTableHeader, JTextComponent, JToolBar, JToolTip, JTree, JViewport

see http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html

If you had meant some thing like draging a file on to some visual component then check this

Forced accept.

EE Admin

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now