I have used
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.
I have used
Last edited by stresstedout; March 30th, 2014 at 06:22 PM.
I don't understand what you are trying to do.need help to assign a specific label to 1 drop point that matches its statement.
I assume that "assign a specific label to 1 drop point" means setting the text of a JLabel object.
What does "matches its statement" mean? That sounds like something is being compared. What is "its statement"?
What is the contents of the values array?
If you don't understand my answer, don't ignore it, ask a question.
1) the
Last edited by stresstedout; March 30th, 2014 at 06:22 PM.
Is this it:i would like the draggable label "moon" to only accept the drop when it is dragged to the statement cat jumped over the moon
there is a JLabel with "moon" that is a draggable source
there is a JLabel with "cat jumped over the moon" that is a drag target
If the "moon" label is dragged to the "cat jumped over the moon" label, it should be accepted
The reason it is to be accepted is because "cat jumped over the moon" contains the substring: "moon"
If you don't understand my answer, don't ignore it, ask a question.
yes u got it, my explaining skills are rubbish.
Look at the String class for a method to find a substring in another String.
If you don't understand my answer, don't ignore it, ask a question.
This is my whole code for this task.. have i done it wrong?
Last edited by stresstedout; March 30th, 2014 at 06:22 PM.
Does it work? What happens when the code is executed?have i done it wrong?
If you don't understand my answer, don't ignore it, ask a question.
yes it works, the drop
Last edited by stresstedout; March 30th, 2014 at 06:22 PM.
The code doesn't agree with what you are asking. There is NOT a String: "cat jumped over the moon" in the code.
The code doesn't do what I suggested in post#4: accept the drop if the target String contained the dragged String
If you don't understand my answer, don't ignore it, ask a question.
there is a
Last edited by stresstedout; March 30th, 2014 at 06:22 PM.
Before you can write code for a program you need to decide what it is supposed to do.
Look at post#4 and explain what is wrong with what I posted there.
If you don't understand my answer, don't ignore it, ask a question.
Is this it:
there is a JLabel es the statement
Last edited by stresstedout; March 30th, 2014 at 06:23 PM.
Where is the String: "cat jumped over the moon" or just "moon" saved in the program so it can be used to determine if a drop should be accepted?
If you don't understand my answer, don't ignore it, ask a question.
there is no string saved in the program.
???
What are these:
JLabel s1 = new JLabel("Cat jumped over the ");
JLabel moonLabel = new DraggableLabel("moon");
JLabel dogLabel = new DraggableLabel("dog");
JLabel catLabel = new DraggableLabel("cat");
JLabel MouseLabel = new DraggableLabel("mouse");
Component droplabel = new DropTargetTextArea("moon", "dog","cat","mouse");
I see lots of Strings in the program.
If you don't understand my answer, don't ignore it, ask a question.
sorry i thought u meant like saved in database or somthing
Time to do some design work. What Strings should be define where for what you want the code to do.
If you don't understand my answer, don't ignore it, ask a question.
1)
Last edited by stresstedout; March 30th, 2014 at 06:23 PM.
How does the target know what String to accept if it is passed 4 Strings?
What is the purpose of the components: s1(the second one) and dropLabel? Doesn't there need to be a drop target for each incomplete sentence?
You need to spend more time on the design. Post#19 has left off the String "door" that would be dropped onto the s1(second one) label.
If you don't understand my answer, don't ignore it, ask a question.
"drop labe
Last edited by stresstedout; March 30th, 2014 at 06:23 PM.
If there is only one drop target what is the second s1 for?
Why are 4 Strings passed to the DropTargetTextArea constructor?
If you don't understand my answer, don't ignore it, ask a question.
it was just an example.. ill just sort out the layout and add the sentence to stop the confusion
It's better when posting code to remove the unneeded and confusing stuff to show a clean example of what you are trying to do.
If you don't understand my answer, don't ignore it, ask a question.
i am having some difficulty with the design, it currently looks like this.. but when i get it working i will fix the design. please can we carry on with the m
Last edited by stresstedout; March 30th, 2014 at 06:23 PM.