Page 3 of 3 FirstFirst 123
Results 41 to 47 of 47
Like Tree1Likes

Thread: need help: writing an interface

  1. #41
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,876
    Rep Power
    5

    Default Re: need help: writing an interface

    None, I don't recommend design patterns either. But that's just me.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  2. #42
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: need help: writing an interface

    Quote Originally Posted by willemjav View Post
    Where do I need to add the listener to?
    I prefer to create a PropertyChangeSupport instance as part of my GUI, and pass the reference to each component that needs to fire or receive property changes.
    Get in the habit of using standard Java naming conventions!

  3. #43
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: need help: writing an interface

    Quote Originally Posted by willemjav View Post
    What lit. would you recommend concerning design patterns?
    This book is great: http://www.amazon.com/Effective-Java.../dp/0321356683 As it says, it's not for beginners. But I think it would be worth reading even if you don't understand all of it right away.
    Get in the habit of using standard Java naming conventions!

  4. #44
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default Re: need help: writing an interface

    Quote Originally Posted by gimbal2 View Post
    None, I don't recommend design patterns either. But that's just me.
    Well, you don't have to apply those design patterns as if they were the holy scriptures, but it certainly is worth a good read ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #45
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: need help: writing an interface

    Thanks for your unifying comments, IŽll look into that book, because books never do any harm, right!
    Concerning the comment of kjkrum, I see now two ways of doing it:
    1) using the addPropertyChangeListener which you override, right (I hope I use the right term)?
    2) or moving a ref of the PropertyChangeSupport around How to Write a Property Change Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)

    I tried out both and used the first one show in the previous code example.

  6. #46
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default Re: need help: writing an interface

    Quote Originally Posted by willemjav View Post
    Thanks for your unifying comments, IŽll look into that book, because books never do any harm, right!
    Concerning the comment of kjkrum, I see now two ways of doing it:
    1) using the addPropertyChangeListener which you override, right (I hope I use the right term)?
    2) or moving a ref of the PropertyChangeSupport around How to Write a Property Change Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)

    I tried out both and used the first one show in the previous code example.
    If you don't want to buy the 'Gang Of Four' book, here's a quite complete patterns listing: Java Design Patterns Programming Reference and Examples
    Maybe you're also interested in 'refactorings'; those are small transformations of existing code, making it 'better' wihout breaking the original behaviour: Refactoring

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #47
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 1
    Last Post: 07-08-2012, 05:23 PM
  2. writing a program to interface with other programs
    By gib65 in forum Advanced Java
    Replies: 4
    Last Post: 11-04-2011, 10:09 PM
  3. Replies: 1
    Last Post: 02-27-2010, 01:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •