Results 1 to 2 of 2
  1. #1
    slakkas is offline Member
    Join Date
    Feb 2011
    Rep Power

    Default Structuring GUI elements and eventlisteners


    I have a class that contains a lot of GUI objects, and a lot of eventlisteners.

    To structure my application better, I would like to split this class into several
    classes, where each class represents one type of GUI elements (e.g. a certain type of buttons). I would of course also need one main class that puts it all together.

    In the eventlisteners of the GUI elements I sometime refer to other GUI elements (e.g. hide a certain panel when a button is clicked), which is trivial when all the elements are contained in the same class.

    However, if I split my class into several classes, how should I structure these classes and/or my eventlisteners so that I am still capable of making changes to the other GUI elements?


  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power


    The answer to this question is complex and very situation dependent. My basic answer to "how should I strucuture" would be 'whatever works' (but you should ask yourself why you want to restructure). Generally speaking, you must think about how to create classes that are loosely coupled to each other - through the use of abstraction (interfaces, abstract classes, and encapsulation) - so that they can be re-used and changed without the need for a full retrofit of everything else.

Similar Threads

  1. multiple windows and eventlisteners
    By kmyr in forum New To Java
    Replies: 3
    Last Post: 01-10-2010, 02:26 PM
  2. what does <Elements> mean
    By JordashTalon in forum New To Java
    Replies: 1
    Last Post: 01-31-2009, 11:19 PM
  3. Negative elements
    By in forum New To Java
    Replies: 6
    Last Post: 12-15-2008, 05:48 AM
  4. a few questions on structuring my program...
    By sdkevinb in forum New To Java
    Replies: 0
    Last Post: 02-06-2008, 07:48 AM
  5. structuring the program
    By ephem in forum New To Java
    Replies: 1
    Last Post: 12-24-2007, 09:53 PM

Posting Permissions

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