How to properly construct a java gui framework?

Discussion in 'Java' started by ***C.Steamer***, Oct 20, 2004.

  1. Basically I need to know how to set up a basic gui framework. I have heard
    of the MVC approach but either I don't fully understand it or it doesn't
    work properly for my needs. I simpley want to know a common structure how
    most Java Applications will be constructed. Mainly, Should I have Say a
    JFrame class that calls a MainPanel which in turn sets up all the Panels for
    the program, and then say a ControllerClass which sets up all the
    components. What do I do with the data. Specifically I am currently making a
    simpe java card game application and I do that. I have a buch of Panels that
    represent say my hand, or the deck. Know say I want to remove a card from
    the display (say someone selected it to play). Should my panel class handle
    all this or should there be some other type of class to handle user inputs
    like perhaps a controller class. Obviously there must be a somewhat simple
    way to organize the gui with the controls of a program. Any help would be
    appreciated. I used the game as an example but this should be common to any
    application on how to set up a organized java app so it is somewhat
    managable and upgradable.

    Thanks
    ***C.Steamer***, Oct 20, 2004
    #1
    1. Advertising

  2. ***C.Steamer***

    steve Guest

    On Wed, 20 Oct 2004 11:11:12 +0800, C.Steamer*** wrote
    (in article <kHkdd.36040$qU.8422@clgrps13>):

    > Basically I need to know how to set up a basic gui framework. I have heard
    > of the MVC approach but either I don't fully understand it or it doesn't
    > work properly for my needs. I simpley want to know a common structure how
    > most Java Applications will be constructed. Mainly, Should I have Say a
    > JFrame class that calls a MainPanel which in turn sets up all the Panels for
    > the program, and then say a ControllerClass which sets up all the
    > components. What do I do with the data. Specifically I am currently making a
    > simpe java card game application and I do that. I have a buch of Panels that
    > represent say my hand, or the deck. Know say I want to remove a card from
    > the display (say someone selected it to play). Should my panel class handle
    > all this or should there be some other type of class to handle user inputs
    > like perhaps a controller class. Obviously there must be a somewhat simple
    > way to organize the gui with the controls of a program. Any help would be
    > appreciated. I used the game as an example but this should be common to any
    > application on how to set up a organized java app so it is somewhat
    > managable and upgradable.
    >
    > Thanks
    >
    >
    >


    you need to subclass it.

    inside your JPanel , have it call other classes, for the sake of your
    example, in a class called , perhaps "hand"


    hand.addcard()
    hand.remove card()
    hand.countcards()
    hand.returncurrentcards()

    etc

    to remove a card , simply call hand.removecard(card)
    subclass it down to it's most basic operation, do not just write an
    extension to JPanel , and stick all the shit in it , or it will end up as a
    very big JPanel class.


    The advantage , with this , is that there maybe some operations that can be
    run in parallel.
    By subclassing it out , you can fire up multiple processing threads.

    if you have a large Jpanel, You COULD put all your graphic elements into
    it.
    But if instead you subclass out each part of your larger Jpanel to other
    Jpanels (for example 5 JPanels), then you could fire up 5 threads & process
    all 5 areas at the same time, leading to a faster GI update.

    Steve
    steve, Oct 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Moskowitz
    Replies:
    3
    Views:
    539
    David Moskowitz
    Feb 23, 2006
  2. David Moskowitz
    Replies:
    6
    Views:
    581
    Nick Kew
    Feb 23, 2006
  3. Replies:
    0
    Views:
    322
  4. Mukesh
    Replies:
    4
    Views:
    622
    Paul N
    Mar 26, 2010
  5. Rishipal Singh
    Replies:
    3
    Views:
    118
    Jeff Higgins
    Apr 21, 2014
Loading...

Share This Page