Yes it doesn't. That is what you are supposed to add for this test:
Change the code so it accepts one of the dropped Strings and rejects the other dropped String.
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.
Yes it doesn't. That is what you are supposed to add for this test:
Change the code so it accepts one of the dropped Strings and rejects the other dropped String.
If you don't understand my answer, don't ignore it, ask a question.
i have tried several times but i keep ending up with the same code. :'(
is there anything u can suggest to help me with this bit of the code?
I'll repeat what has been said before:
What variable is the Dropped String in when it is received? You need the name of the variable.
Write an if statement that compares that dropped String against one of the two possible Strings that can be dropped: "test" or "testing". I'll Pick "test"
If the dropped String is "test" print a message saying "reject the drop"
otherwise print a message saying " accept the drop"
If you don't understand my answer, don't ignore it, ask a question.
i know what you are sayin, i am just a tad confused about how to code it all.
Can you write these 5 lines:
if (match test) {
print accept
}else{
print reject
}
Use the variable that has the Dropped String in it. Place those 5 lines after the dropped String is assigned a value.
If you don't understand my answer, don't ignore it, ask a question.
That's a strange question to ask about your code. Did you write that code or was it copied from someone else's work? I was assuming that you had written it and knew how it worked.
Wasn't this discussed earlier? Your post#59 answered this question. Have you forgotten all the the previous things that were discussed in this thread? That is going to make it much harder if we have to continually go over things that were previously covered.
If you don't understand my answer, don't ignore it, ask a question.
no i have written the code myself, but im just getn confused with the different terms being used. i went to get some rest gna try and do it now
--- Update ---
This is what im all puzzed about. is it somthing like this?String is assigned a value
Last edited by stresstedout; March 4th, 2014 at 01:38 AM.
This statement assigns a value to a String variable:To the left of the = is the variableString aStr = "a value here"; // assign a value to a String variable
to the right of the = is the value being assigned to the variable
If you don't understand my answer, don't ignore it, ask a question.
please can you see post#83
is this correct?
No. Use the equals() method to compare Strings.
The code only needs to compare the dropped String against the String to be accepted. Any other dropped String is to be rejected.
The logic is close, but the coding is wrong.
If you don't understand my answer, don't ignore it, ask a question.
is this correct?
Last edited by stresstedout; March 4th, 2014 at 01:38 AM.
Not yet. What if there are hundreds of dropped String possibilities? The code should only test for the String(s) it is going to accept.
If you don't understand my answer, don't ignore it, ask a question.
so there should be no code for the line else if? this code is still not makin a difference so im guessing it not correct?
Last edited by stresstedout; March 4th, 2014 at 01:38 AM.
The else block is executed when the if condition is false. That will be the case for all of the Strings that do not match the accepted String(s).
See posts #64 and #80
If you don't understand my answer, don't ignore it, ask a question.
so now i need to add this to my database code which i have done, it still allows the text to go in every label.
so now i need to set each labelicon to match the word, so it knows which ones to accept right??
You need to work with the testing program some more before trying to copy the logic to the larger program.
Have you made the changes that rejects the String instead of printing a message?
If you don't understand my answer, don't ignore it, ask a question.
no atm it doesnt actually reject anything.. this is the full code of the testing program..
Last edited by stresstedout; March 4th, 2014 at 01:39 AM.
Look at posts #64 and #80 for how to code the elseatm it doesnt actually reject anything
If you don't understand my answer, don't ignore it, ask a question.
i have looked at them but still unsure of how to do this.
Compare the else in post #64 and #80 with the else code in post#93
If you don't understand my answer, don't ignore it, ask a question.
is it somthing like above??
Last edited by stresstedout; March 4th, 2014 at 01:39 AM.
Sorry, that very short piece of code doesn't show what the code is doing.
It does NOT look like the code in posts #64 and #80
If you don't understand my answer, don't ignore it, ask a question.
i am getting this error
Exception in thread "AWT-EventQueue-0" java.awt.dnd.InvalidDnDOperationException: invalid rejectDrop()
at sun.awt.dnd.SunDropTargetContextPeer.rejectDrop(Su nDropTargetContextPeer.java:645)
Drag action End
at java.awt.dnd.DropTargetContext.rejectDrop(DropTarg etContext.java:208)
at java.awt.dnd.DropTargetDropEvent.rejectDrop(DropTa rgetDropEvent.java:242)
at javaapplication24.DragAndDropExample$DropTargetTex tArea.drop(DragAndDropExample.java:177)
at java.awt.dnd.DropTarget.drop(DropTarget.java:450)
at sun.awt.dnd.SunDropTargetContextPeer.processDropMe ssage(SunDropTargetContextPeer.java:537)
at sun.awt.dnd.SunDropTargetContextPeer$EventDispatch er.dispatchDropEvent(SunDropTargetContextPeer.java :851)
at sun.awt.dnd.SunDropTargetContextPeer$EventDispatch er.dispatchEvent(SunDropTargetContextPeer.java:775 )
at sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTar getEvent.java:48)
at java.awt.Component.dispatchEventImpl(Component.jav a:4716)
at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
at java.awt.Component.dispatchEvent(Component.java:46 87)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
at java.awt.LightweightDispatcher.processDropTargetEv ent(Container.java:4566)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4417)
at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719 )
at java.awt.Component.dispatchEvent(Component.java:46 87)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:723)
at java.awt.EventQueue.access$200(EventQueue.java:103 )
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 693)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:91)
Last edited by stresstedout; March 4th, 2014 at 01:39 AM.
It looks like the code will call the reject method more than one time. Once in the else and once after that.
Where is the if statement that tests if the dropped String is to be accepted?
If you don't understand my answer, don't ignore it, ask a question.