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.

Page 7 of 8 FirstFirst ... 5678 LastLast
Results 151 to 175 of 192

Thread: drag and drop word to match image

  1. #151
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    Do I need to delete any part of the code in post #114 or do I add to it??
    This is 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.
    What is your question about post #114?
    If you don't understand my answer, don't ignore it, ask a question.

  2. #152
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    I mean post 144..

    The question is on there

  3. #153
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    See post#133 for an example of a constructor that takes a String as argument.

    That is VERY BASIC java programming. If you can not code a constructor now after so much coding, you need to go back and study the tutorial and code some simple programs before trying to code this program.
    Providing Constructors for Your Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    Passing Information to a Method or a Constructor (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    If you don't understand my answer, don't ignore it, ask a question.

  4. #154
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    are you able to tell me what i am doing wrong please
    Last edited by stresstedout; March 4th, 2014 at 01:42 AM.

  5. #155
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    public class DropTarget(int testing, int test){
    What are supposed to be in the two int values passed to the constructor: testing and test?

    What happened to the definition for:
    public static class DropTargetTextArea ...
    That is the class whose constructor needs to be changed.


    Undo those changes and go back to the last code that worked and start over.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #156
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    Quote Originally Posted by Norm View Post
    public static class DropTargetTextArea ...
    That is the class whose constructor needs to be changed.


    Undo those changes and go back to the last code that worked and start over.

    are you able to tell me in steps on how to do this?
    Last edited by stresstedout; March 4th, 2014 at 01:43 AM.

  7. #157
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    Those changes do not make any sense.

    Go back to the last version of the code that compiled and executed and start again.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #158
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    i have done that, but you said i cant have the strings in the method. i understand how constructors work but i think im just so stressted out about getting this done my head is not working atm.

    Please can you help me somehow. or a step by step on how to achieve this?

  9. #159
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    I have told you what needs to be done. Re-read the posts on the thread.

    This is the problem you need to solve:
    If there are 30 images as drop targets, each with a different String to be shown with them when the user correctly drops a String from a DraggableLabel, how will those 30 images know what String they should show?
    The String needs to be passed into the class that holds the image via the class's constructor.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #160
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    i know you have given those documents to read through, but i dont understand on how to change the current to code.
    i have read the thread several times but im not getting any where. im lost

  11. #161
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    Ok, put the current program aside and work on a new very small test program that uses the technique you need:
    Write a test program that
    has a constructor that takes a String as arg
    the constructor saves the String in a class variable
    Also the class has a method that takes a String as an arg
    and compares that arg to the String that was passed to the constructor
    and returns true if they match, else false

    Add a main() method to the class that
    creates an instance of the class passing the constructor a String
    and then calls the compare method of the class several times with different Strings
    and prints out the results returned by the compare method.
    If you don't understand my answer, don't ignore it, ask a question.

  12. #162
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    i seriously dont have time to be making small programs.. i need to submit this tonight.

  13. #163
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    You said: im lost
    I think you need to work on simpler projects to learn the techniques needed for this larger program.
    The current program you are/were working on was a test program to get the techniques for drag and drop.
    When that is working it will take several days for you to rewrite the large program that will do the final project.
    If you don't understand my answer, don't ignore it, ask a question.

  14. #164
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    please can you tell how to code this constructor to pass the string. if i dont hand this 2maro i will fail the whole module. please try to understand. once i get this working then i have a good few hours to work on the final project, i may not have it fully complete but atleast i will get marks for somthing.. please i beg ya

  15. #165
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    how to code this constructor to pass the string.
    See the constructor for the DraggableLabel class. It has a String as arg
    If you don't understand my answer, don't ignore it, ask a question.

  16. #166
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    yes it does. :'(

  17. #167
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    ??? What are you waiting for? There is an example that you coded in the program. Copy the technique shown there.
    If you don't understand my answer, don't ignore it, ask a question.

  18. #168
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    like this ??
    Last edited by stresstedout; March 4th, 2014 at 01:43 AM.

  19. #169
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    Did that compile and execute and do what you wanted?
    If not post the errors or explain what happened and what you want to be different.
    If you don't understand my answer, don't ignore it, ask a question.

  20. #170
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    i tried this yesterday that code but it didnt work, here is the error.

    Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsExce ption: Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:525)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:41 1)
    at com.mysql.jdbc.SQLError.createCommunicationsExcept ion(SQLError.java:1117)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:350)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(Connecti onImpl.java:2408)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(Co nnectionImpl.java:2445)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2230)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImp l.java:813)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connect ion.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:525)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:41 1)
    at com.mysql.jdbc.ConnectionImpl.getInstance(Connecti onImpl.java:399)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:334)
    at java.sql.DriverManager.getConnection(DriverManager .java:579)
    at java.sql.DriverManager.getConnection(DriverManager .java:221)
    at javaapplication24.JavaApplication24.main(JavaAppli cation24.java:44)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Du alStackPlainSocketImpl.java:69)
    at java.net.AbstractPlainSocketImpl.doConnect(Abstrac tPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress( AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractP lainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:157)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:391)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at java.net.Socket.<init>(Socket.java:425)
    at java.net.Socket.<init>(Socket.java:241)
    at com.mysql.jdbc.StandardSocketFactory.connect(Stand ardSocketFactory.java:259)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
    ... 15 more
    Java Result: 1

  21. #171
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    Sorry, I don't know anything about databases. Forget about using databases. Use image files in a folder.

    What happened to the test program that was to have two different DraggableLabel objects and two DropTargetTextArea objects with different Strings so that the DnD logic could be tested?
    If you don't understand my answer, don't ignore it, ask a question.

  22. #172
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    do you know what this means?


    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - constructor DropTargetTextArea in class javaapplication24.DragAndDropExample.DropTargetTex tArea cannot be applied to given types;
    required: java.lang.String
    found: no arguments
    reason: actual and formal argument lists differ in length
    at javaapplication24.DragAndDropExample.main(DragAndD ropExample.java:66)
    Java Result: 1

  23. #173
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    required: java.lang.String
    found: no arguments
    reason: actual and formal argument lists differ in length
    The constructor takes a String but there wasn't a String provided.
    If you don't understand my answer, don't ignore it, ask a question.

  24. #174
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drag and drop word to match image

    Quote Originally Posted by Norm View Post
    The constructor takes a String but there wasn't a String provided.



    here is the full code...

    where am i going wrong?
    Last edited by stresstedout; March 4th, 2014 at 01:44 AM.

  25. #175
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: drag and drop word to match image

    The DropTargetTextArea constructor takes a String but there wasn't a String provided.
    Add a String as an arg in the new statement.
    If you don't understand my answer, don't ignore it, ask a question.

Page 7 of 8 FirstFirst ... 5678 LastLast

Similar Threads

  1. Drag and Drop in JTrees
    By helloworld922 in forum Java Swing Tutorials
    Replies: 4
    Last Post: March 21st, 2014, 11:16 AM
  2. [SOLVED] Drag and drop in MVC
    By Alice in forum Object Oriented Programming
    Replies: 9
    Last Post: December 9th, 2010, 10:16 PM
  3. Drag and Drop in JTrees
    By helloworld922 in forum Java Code Snippets and Tutorials
    Replies: 2
    Last Post: February 20th, 2010, 03:52 PM
  4. Drag and Drop in JTrees
    By helloworld922 in forum AWT / Java Swing
    Replies: 2
    Last Post: January 19th, 2010, 11:51 PM
  5. 'MouseUp' Drag and Drop Events
    By copeg in forum AWT / Java Swing
    Replies: 0
    Last Post: November 10th, 2009, 07:21 PM