Results 1 to 5 of 5

Thread: What is TransferSupport Class in Java?

  1. #1
    Join Date
    Jul 2006
    Posts
    273

    What is TransferSupport Class in Java?

    I am bit new to the Java, before this I have done C++ and C# programming language. So I don't know much about the Java. I have just completed with some basic coding which can create some buttons, labels, etc. Recently I have studied about the components. In which the TransferSupport Class was not clear to me.! So please tell me what is TransferSupport Class in Java? Any coding would be very grateful.!!
    (\__/)
    (='.'=) This is Bunny. Copy and paste bunny into your
    (")_(") signatureto help him gain world domination

  2. #2
    Join Date
    Mar 2008
    Posts
    672

    Re: What is TransferSupport Class in Java?

    Before moving to the coding I think that you should clear the concepts of that class. Otherwise you will find tough to understand the coding. So I thought to give you some information about the same. TransferSupport Class has an important function to support the transfer process. And for that support it provides several utility methods used to access the details of the data transfer. The TransferSupport class is considered as one of the inner classes of the TransferHandler class. There is no Transfer class in Java 6. There are a number of classes with 'transfer' in the name, but none of them is 'Transfer'.

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: What is TransferSupport Class in Java?

    You should also have the knowledge about the methods used by the drop actions. The following are some of the methods :
    • int getDropAction() - When you drop the transfer, this method returns the chosen action. The action can be Copy, Move or Link.
    • Component getComponent() - This method returns the target component of the transfer.
    • int getUserDropAction() - This method returns the user's chosen drop action. This method throws an exception if transfer is not a drop.
    • int getSourceDropActions() - This method returns the set of actions supported by the source component. Its similar to above method because it also throws an exception if the transfer is not a drop.

  4. #4
    Join Date
    Aug 2006
    Posts
    227

    Re: What is TransferSupport Class in Java?

    I think that you are now familiar with the TransferSupport utility methods, so you can use the following example :
    Code:
    public boolean canImport(TransferSupport transup) {
        if (!transup.isDataFlavorSupported(stringFlavor)) {
            return false;
        }
    
        DropLocation loc = transup.getDropLocation();
    
        return shouldAcceptDropLocation(loc);
    }
    
    public boolean importData(TransferSupport transup) {
        if (!canImport(sup)) {
            return false;
        }
    
        Transferable t = transup.getTransferable();
        String data = t.getTransferData(stringFlavor);
    
        DropLocation loc = transup.getDropLocation();
    
        insertAt(loc, data);
    
        return true;
    }
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  5. #5
    Join Date
    Jul 2006
    Posts
    289

    Re: What is TransferSupport Class in Java?

    I got more methods for the drop actions which is described as follows :
    • DataFlavor[] getDataFlavors() - This method returns all the data flavors supported by this component.
    • boolean isDataFlavorSupported(DataFlavor) - If the specified DataFlavor is supported, then this method returns true.
    • Transferable getTransferable() - This method returns the Transferable data for this transfer. This method is not recommended because it is more efficient to use one of these methods to query information about the transfer than to fetch the transferable.
    Signatures reduce available bandwidth

Similar Threads

  1. Converting java class to java bean class
    By Ucchal in forum Software Development
    Replies: 6
    Last Post: 09-08-2010, 10:24 AM
  2. JCheckBoxMenuItem class of java
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 18-02-2010, 12:11 PM
  3. JDesktopPane class of java
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 18-02-2010, 08:14 AM
  4. JList class of java
    By Owen Fernandes in forum Software Development
    Replies: 5
    Last Post: 17-02-2010, 08:19 AM
  5. Java Programming Language Basics: Reflection Basics and Class Class
    By mayuri_gunjan in forum Guides & Tutorials
    Replies: 6
    Last Post: 29-08-2005, 12:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,577,197.57852 seconds with 16 queries