Change the constructor in the class that needs to receive the String to be accepted.
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.
Change the constructor in the class that needs to receive the String to be accepted.
If you don't understand my answer, don't ignore it, ask a question.
what do i change dragdropexample to?
i only have class do i need another?
Last edited by stresstedout; March 4th, 2014 at 01:41 AM.
What are those int values used for? Why are they in the testing program's constructor?
Think about what the program is supposed to do: Allow the user to drag a String from one component to another component where the String will either be accepted or rejected. When the target component is built using a constructor the String that it will use to determine acceptance must be passed to it and saved so it can be used to test with when the user drags and drops a String onto it.
If you don't understand my answer, don't ignore it, ask a question.
dragContents? DropTargetTextArea
is one them correct??
Last edited by stresstedout; February 27th, 2014 at 09:41 PM.
How many classes are in the program?
Forget the testing class that builds the frame that has the components added to it for the GUI.
From the other classes,
which class has the source of the dragged String.
which class is the target where the String is dragged to where it is either accepted or rejected
Both of the above classes need to have a String passed to their constructor.
The source class to define the String to drag
The target class to define the String that is to be accepted
If you don't understand my answer, don't ignore it, ask a question.
which class has the source of the dragged String. answer DraggableLabel
which class is the target where the String is dragged to where it is either accepted or rejected answer DropTargetTextArea
Ok, now write the constructors for those two classes to take a String and save it for use.
If you don't understand my answer, don't ignore it, ask a question.
they currently look like this
Last edited by stresstedout; March 4th, 2014 at 01:41 AM.
Then you need to change the one that does not take a String so that it does.
If you don't understand my answer, don't ignore it, ask a question.
What is that code posted for?
I'm done for tonight.
If you don't understand my answer, don't ignore it, ask a question.
i dont understand how to do this or why the drop target need the string?
--- Update ---
i have up until march 3 2014 to complete this, i know it takes me time to understand what i am doing but please help me i need to fix this and get the exception working where the drop target decides which string to take. PLEASE HELP ME
Last edited by stresstedout; February 28th, 2014 at 12:03 AM.
If it doesn't need a String, then write the program without a String.why the drop target need the string
Where will the String the drop target will use for that come from?the drop target decides which string to take
If you don't understand my answer, don't ignore it, ask a question.
it will come from the draggablelabel class right?
What String will be used by the DropTargetTextArea object to compare against the String from the DraggableLabel objects?
If you don't understand my answer, don't ignore it, ask a question.
the strings need to assigned.. i have delted that from the method.
Where do the Strings come from?the strings need to assigned
In the final program, there can be many drop targets. Each will have a different String. How will each of those drop targets get the Strings they need?
If you don't understand my answer, don't ignore it, ask a question.
isit by doing what u said.. passing the strings through the constructor?
Yes, that is how I would do it.
If you don't understand my answer, don't ignore it, ask a question.
please can you start me off on how to allow this to take the string for this piece of code.
Last edited by stresstedout; March 4th, 2014 at 01:42 AM.
That is invalid code. There should not be any "s
If you don't understand my answer, don't ignore it, ask a question.
i have updated it
Does it compile and execute without errors now?
Does it work like you want?
If you don't understand my answer, don't ignore it, ask a question.
See post#133 for an example of a constructor that takes a String as argument.
This is post#114Refer to post #114
What is your question about post #114?Don't be in a hurry to move the testing code into the main program. It will be easier to work out the techniques in the test program.
If you don't understand my answer, don't ignore it, ask a question.
Ive seen that and I understand iy but im just confused on how to implement it with code.
Do I need to delete any part of the code in post #114 or do I add to it??