Hi,
Can anyone give me any tips or help me in anway?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi,
Can anyone give me any tips or help me in anway?
Last edited by stresstedout; March 4th, 2014 at 01:34 AM.
Possible? Yes.
Java Drag and Drop Tutorial.
i know how to do drag and drop, the thing im not sure how to program is if it matches the images to sit below the image, if incorrect to go back to the list.
That's just logic:
if ( imageMatchesWords ) { // accept it } else { // put it back where it came from }
Writing Drag and Drop code can be quite complicated if the components don't support it directly. Maybe you should look at selecting objects with mouse clicks instead of DnD.
If you don't understand my answer, don't ignore it, ask a question.
I need to get to the grips of getting DnD done cus i need the marks for my project.
I know its complicated but i just need to know weather or not i can drage and drop in to a label and get it sit under the image
I think its possible but I have no idea how hard it would be for you to do it. I wrote some DnD code 8 years ago and haven't worked with it since then.
If you don't understand my answer, don't ignore it, ask a question.
i have managed to do drag the selected text into a textarea, however i will need to change to this to a label.
I need the text which the user drag to match with the image and if it matches to go in the text area if not then to go back on the panel.
This is where i am going to struggle now.
someone above gave me a tip and said it was easy, but i may need some help. any tips
What is the source of the text that is being dragged? Have you written a small test program that does a drag and drop from a source to a target?
If you don't understand my answer, don't ignore it, ask a question.
The code below drag and drop into a textarea, when i try to do the drop to a label i get red lines errors.
Last edited by stresstedout; March 4th, 2014 at 01:35 AM.
The posted code is missing all the import statements.
If you don't understand my answer, don't ignore it, ask a question.
added them
What is your next step?
The posted code must be very old. It uses awt classes vs swing
If you don't understand my answer, don't ignore it, ask a question.
I need the text which the user drag to match with the image and if it matches to go in the label if not then to go back on the panel.
This is where i dont know where to begin.
First you need to make a component that is a target for a drop gesture. The code for the drop location would look at the "text" that was being dragged and make the decision if it matches the target site or not.
If you don't understand my answer, don't ignore it, ask a question.
do u have any sample code or or know of any tutorials that can help?
What about the code you just posted?
If you don't understand my answer, don't ignore it, ask a question.
i am having problems with changing the drop textarea to label and for to print the word on the label like it does in the textarea
Copy the full text of the error messages and paste them here.i am having problems
If you don't understand my answer, don't ignore it, ask a question.
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - javaapplication24.GridLayoutTest.DropTargetJLabel is abstract; cannot be instantiated
at javaapplication24.GridLayoutTest.<init>(GridLayout Test.java:81)
at javaapplication24.GridLayoutTest$DropTargetJLabel. main(GridLayoutTest.java:225)
Java Result: 1
What code is that error message for? The posted code has about 165 lines and is named: DragAndDropExample.
Do your testing on the posted code BEFORE making a larger program. Work out the coding techniques with a small program first.
If you don't understand my answer, don't ignore it, ask a question.
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - incompatible types: javaapplication24.DragAndDropExample.DropTargetjla bel cannot be converted to java.awt.Component
at javaapplication24.DragAndDropExample.main(DragAndD ropExample.java:53)
Java Result: 1
Last edited by stresstedout; March 4th, 2014 at 01:35 AM.
You need to post all of the code.DropTargetjlabel cannot be converted to java.awt.Component
And all of the error messages. You mention 3 errors but only post the text of one.
If you don't understand my answer, don't ignore it, ask a question.
the error only says
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - incompatible types: javaapplication24.DragAndDropExample.DropTargetjla bel cannot be converted to java.awt.Component
at javaapplication24.DragAndDropExample.main(DragAndD ropExample.java:53)
Java Result: 1
BUILD SUCCESSFUL (total time: 4 seconds)
Last edited by stresstedout; March 4th, 2014 at 01:35 AM.