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 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 67

Thread: accept only assigned label dnd

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    What method? More needs to be done than change a method. Without a design coding is a waste of time.i
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    design is sorted
    Last edited by stresstedout; March 30th, 2014 at 06:21 PM.

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    What is the design for how the program should work? Decide on what the program should do before writing code.
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    i would it to do as you suggested in post#4..

    by design i am guessing you meant layout.. there in only one sentence and one draggable source in this code.
    Last edited by stresstedout; March 30th, 2014 at 06:21 PM.

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    Does that code do what you want now?
    What happens when you execute it?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    Quote Originally Posted by Norm View Post
    Does that code do what you want now?
    What happens when you execute it?
    No it takes ANY draggable source and then rejects all the others. How do I assign it so that sentence only takes "moon" and rejects the other sources?

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    it takes ANY draggable source
    How are you testing it to see that it takes all draggable sources? What draggable sources are there in the program to test with?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    Quote Originally Posted by Norm View Post
    How are you testing it to see that it takes all draggable sources? What draggable sources are there in the program to test with?
    These are the draggable sources:
    Last edited by stresstedout; March 30th, 2014 at 06:21 PM.

  9. #34
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    Those draggable sources are NOT in the code in post#29 that I was using for testing.

    What are all the Strings in the constructor for the DropTargetTextArea class for in post#33? They were NOT in the code in post#29.

    Why did you change that?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    this is t
    Last edited by stresstedout; March 30th, 2014 at 06:21 PM.

  11. #36
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    Did you see my questions about the 4 Strings in the constructor? Why are they there? What does the class do with them?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    it relates to the drop label. i have 4 drop labels and in the DropTargetTextArea any four can be dropped.

    if i add 5th drop label i will need to also add the string the the DropTargetTextArea for it to be dropped

  13. #38
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    What does the class do with the Strings that are passed to it?

    if i add 5th drop label i will need to also add the string the the DropTargetTextArea for it to be dropped
    What if there are 50 or 200?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    im not sure, i have made a mistake.
    what would i need to do to fix this?

  15. #40
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    What do you need to fix? What is the program supposed to do? What values does the DropTargetTextArea class need to have to do its job? What is the DropTargetTextArea class's job?

    These are all questions that should have been asked and answered when the design for the program was made.
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    Quote Originally Posted by Norm View Post
    What do you need to fix? What is the program supposed to do? What values does the DropTargetTextArea class need to have to do its job? What is the DropTargetTextArea class's job?

    These are all questions that should have been asked and answered when the design for the program was made.
    1) what the program should do
    If the
    Last edited by stresstedout; March 30th, 2014 at 06:21 PM.

  17. #42
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    the "cat jumped over the moon" label,
    Where is that label? I don't see one with those words in the text.
    The drop location in the code is EMPTY, there is no text in it.

    have 1 only string value which it will either accept or reject
    Yes, that sounds like what it should have and do.

    Rewrite the code so it does that.
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    JLabel s1 =
    Last edited by stresstedout; March 30th, 2014 at 06:24 PM.

  19. #44
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    if i was to add another 2 sentences how would i implement this?
    Each new drop target would be a new instance of the DropTargetTextArea class.
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    not sure how to implement this. please can you give me an example

  21. #46
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    Sorry, I don't know what you are asking for. What part are you having problems with?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    how do i do this??

    Each new drop target would be a new instance of the DropTargetTextArea class.

  23. #48
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    Are you asking how to create an instance of a class? Use a new statement. The current code is full of them.
    For example:
                   JPanel gridPanel = new JPanel(new GridLayout(4, 4, 5, 5)); 
                    JPanel flowPanel = new JPanel();
       ...
          Component droplabel = new DropTargetTextArea("moon", "dog","cat","mouse");

    All those statements create new instances of some class.
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: accept only assigned label dnd

    but i
    Last edited by stresstedout; March 30th, 2014 at 06:24 PM.

  25. #50
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: accept only assigned label dnd

    i thought i was doing them wrong and thats why i took them out.
    You are correct, the code I posted was NOT how the code is supposed to be. I just copied some code from your last post to show you how you have used new statements many times in the code.

    The constructor should have the String that the instance of the class will accept. Each instance can have its own String.
    If you don't understand my answer, don't ignore it, ask a question.

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. How to not accept empty jfield?
    By myexternall11 in forum Java Theory & Questions
    Replies: 1
    Last Post: February 20th, 2012, 04:38 AM
  2. [SOLVED] Need help with updating label
    By Neacel in forum AWT / Java Swing
    Replies: 5
    Last Post: January 22nd, 2012, 02:38 PM
  3. JTree DnD Problem
    By hafunui in forum AWT / Java Swing
    Replies: 3
    Last Post: August 12th, 2011, 10:33 PM
  4. Label not showing up.
    By joshft91 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 1st, 2011, 03:36 PM
  5. Dropping to graphic element dragged from JList
    By tua1 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 29th, 2008, 08:22 AM