Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5838675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:29:35+00:00 2026-05-22T11:29:35+00:00

I want the following behavior in a Java Swing application: User drags and drops

  • 0

I want the following behavior in a Java Swing application:

  1. User drags and drops an icon.
  2. User is prompted with a modal dialog if other icons should also be operated upon.
  3. After the user chooses YES, NO, or CANCEL (or closes the dialog), Java begins operating on (copying/moving) the icons (or on cancel/close does nothing).

Within TransferHandler.canImport() I have visibility to the drop target but not to the icon.

Within TransferHandler.exportDone() I have visibility to the icon but not to the drop target.

Within TransferHandler.importData() I have visibility to both, but by then it’s too late since if I’m performing a TransferHandler.MOVE then TransferHandler.exportDone() has already removed the icon.

Is the behavior I mentioned above possible using Java Swing? If so, what version of the JDK/JRE do I need to use and how do I implement it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:29:36+00:00Added an answer on May 22, 2026 at 11:29 am

    If you want to be able to possibly drag-and-drop items, as well as move/copy them programatically, you need to make sure you have a proper model set up which backs the view. This means you shouldn’t be coding your business logic directly into the GUI code. The model should be simple and independent, focusing on the actual task of managing the data. In your case, you it sounds like you just need to hold some collections of objects and provide methods which move/copy objects from one collection to the other. The code which does this is called the controller (MVC – pardon me if you are already familiar with this pattern). The controller will then update the GUI to reflect the changes. Similarly, your drag-and-drop will trigger a controller action which performs a similar action on the model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to achieve the following: I want a free Application Lifecycle Management
Assume I have a button and I want the following behavior: when I click
I want to achieve the following behavior: Depending on a value use a different
I'm starting with iOS development and I want to implement the following behavior in
In following code, I want to extend the behaviour of a class by deriving/subclassing
I want the following layout to appear on the screen: FieldName 1 [Field input
I want the following functionality using php I have a csv file. Each file
i want the following functionality. input : this is test <b> bold text </b>
Is there a language agnostic algorithm to name tuples? Specifically, I want the following
The problem is following: I want to automate the way my emacs starts. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.