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 7851117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:05:21+00:00 2026-06-02T19:05:21+00:00

i am working with javafx 2.0 and netbean 7.1, I am facing an problem

  • 0

i am working with javafx 2.0 and netbean 7.1, I am facing an problem when doing a drag and drop on a image over a ImageView, .i kept image as a source(one image) and 2 target point(2 box as target point).when trying to drag an image first time, its working fine and after sources image is entered in to target box.and again trying to drag the image, following error is trown “java.lang.IllegalArgumentException: Wrong byte buffer size 18×15 [1080] != 0”

Once the image is moved to the destination object, i need to set the listener to change it as source, i feel that its throwing error in this place..

code am using

public class DragandDropEx extends Application {

    /**
     * @param args the command line arguments
     */
    GridPane Board;
    ImageView deactivateImageView = new ImageView();
    ImageView newImageView = new ImageView();




    final Rectangle target = new Rectangle(0, 0, 50, 50);
    final Rectangle target2 = new Rectangle(0, 0, 50, 50);


    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        target.setFill(Color.CHOCOLATE);
        target2.setFill(Color.BLUE);
        Image image = new Image(getClass().getResourceAsStream("triangle.png"));
        getDeactivateImageView().setImage(image);
        Board = new GridPane();
        primaryStage.setTitle("Drag and Drop");



        createSource(getDeactivateImageView());



        target.setOnDragOver(new EventHandler<DragEvent>() {

            @Override
            public void handle(DragEvent events) {
               events.acceptTransferModes(TransferMode.MOVE);
               events.consume();

                   createTargetDrop(target,0,8);
            }
        });
        target2.setOnDragOver(new EventHandler<DragEvent>() {

            @Override
            public void handle(DragEvent events) {
               events.acceptTransferModes(TransferMode.MOVE);
                events.consume();
                createTargetDrop(target2,0,9);
            }
        });






        Board.add(getDeactivateImageView(), 0, 1);
        Board.add(target, 0, 8);
        Board.add(target2, 0, 9);

        StackPane root = new StackPane();
        root.getChildren().add(Board);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.show();
    }

    private void createSource(final ImageView imageView) {
       imageView.setOnDragDetected(new EventHandler<MouseEvent>() {
             @Override
            public void handle(MouseEvent events) {
                Dragboard storeImage =imageView.startDragAndDrop(TransferMode.MOVE);
                ClipboardContent content = new ClipboardContent();
                content.putImage(imageView.getImage());
                storeImage.setContent(content);                      **//  here i am getting error**
                events.consume();


            }
        });
    }

    private void createTargetDrop(final Rectangle target,final int xCordination,final int yCordination) {

        target.setOnDragDropped(new EventHandler<DragEvent>() {

            @Override
            public void handle(DragEvent event) {
                Dragboard db = event.getDragboard();
                Image dragedImage = db.getImage();
                getNewImageView().setImage(dragedImage);
                getDeactivateImageView().setVisible(false);
                setDeactivateImageView(getNewImageView());
                Board.add(getDeactivateImageView(),xCordination,yCordination );
                event.consume();
                createSource(getDeactivateImageView());                                         // setting listener to new image

            }
        });

    }
}
  • 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-06-02T19:05:23+00:00Added an answer on June 2, 2026 at 7:05 pm

    I guess its about references. I mean you are using same reference to different place. Maybe you should use clone of object. I did not look to code deeply but it looks like you are trying to add same object to different place.

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

Sidebar

Related Questions

In my Fedora box i have JavaFX 2.0 working. But how can i now
I am working on a game in JavaFX and I'm sending people the compiled
I'm working on a project with some friends over Github for a University project.
Environment: Windows 7, NetBean 6.9 (the one including GlassFish v3, Java EE 6), MySQL
I have 3 Webservices which is created with netbean 6.9 when I working on
I'm working on a JMS application. I'm facing a scenario where I need to
We are three developers all working with Netbeans and Java. One developer can access
My JavaFX app is working when executed via the JavaFX Eclipse plugin. But when
I was working with javax.imageio.ImageIO class The one provided by sun doesn't provide support
I have a project i am working on JavaFX 2.0, and it is a

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.