Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java GUI Flow

Options
  • 03-08-2009 10:34am
    #1
    Registered Users Posts: 1,380 ✭✭✭


    I just started on the basics of Swing GUI in Java yesterday for an application I'm developing (2 years Java experience). I got some decent information on Sun's tutorial section about the different components and containers and how to put them together, and I'v made the app's first screen (username & password entry).

    What I'm wondering now is how do I go about making the rest of the app's interface? At the moment I have a AppNameGUI class that creates a frame and the components I need for that initial screen. What do I do then? Create a new class with it's own frame and new components? Remove the existing components and add new ones? I'm just confused as to how best to handle multiple pages of a GUI..


Comments

  • Moderators, Technology & Internet Moderators Posts: 1,335 Mod ✭✭✭✭croo


    if you go to someplace like sourceforge will find many many examples of different approaches in the open source projects there!


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I would create a new class with new components for a new window.


  • Registered Users Posts: 3,945 ✭✭✭Anima


    Why not use tabs? Might be the right tool to use.


  • Registered Users Posts: 569 ✭✭✭none


    Most desktop GUI apps that use a login box, use it in a modal dialog which, after successful authorisation is replaced with a full-featured window (possibly with tabs). So, in this scenario, you need two windows, e.g., JDialog & JFrame.


  • Registered Users Posts: 1,380 ✭✭✭remus808


    I guess what I'm asking is.. Say you have an app, that for whatever reason, has a number of different screens. I'm making a Twitter client so I'l use this example:

    Login -> Post an update -> View updates -> Account details

    So (outside of using tabs - good suggestion), is it more sensible to have:

    1. One class with one frame, which you add and remove elements from

    2. Or something like, LoginGUI, PostGUI etc, where you replace the previous window with a new frame

    Sorry theres probably an obvious path to take in this situation, it just hasn't really presented itself yet and I haven't found any good material to get ideas from.


  • Advertisement
  • Moderators, Technology & Internet Moderators Posts: 1,335 Mod ✭✭✭✭croo


    I think the short answer would be MVC!
    I know many people might associate MVC with a web based app but its origins are in smalltalk with was one of the first object-orientated/event-driven development environments.
    So there would typically be some form of controllers that manages (opens) the different windows (views). And don't forget as a swing app it will be more event-driven and less linear than your example proposes.
    > [Login -> Post an update -> View updates -> Account details]

    And as a desktop based swing app it might, for example, allow multiple windows open at the same time.

    I still suggested downloading some small java app from SourceForge ands looking to see if you can figure out how it works.


  • Registered Users Posts: 1,380 ✭✭✭remus808


    Anima wrote: »
    Why not use tabs? Might be the right tool to use.
    none wrote: »
    Most desktop GUI apps that use a login box, use it in a modal dialog which, after successful authorisation is replaced with a full-featured window (possibly with tabs). So, in this scenario, you need two windows, e.g., JDialog & JFrame.

    Ok so at present my GUI is made up of: GUIManager, which handles opening windows and the transitions between them. LoginScreen, which does what it says on the tin and then gives way to MainTabbedUI, which is really just the container for its 4 tabs which are all abstracted out as classes in themselves - TweetTab, IncomingTab, RepliesTab and SettingsTab. For the record, the only other classes in the program are Main (contains the methods for connecting with the server) and two utility classes (Base64Encoder and XMLParser)

    I'd be very interested as to whether people think I'm sinning against Object Orientation - this is the first complex project I've undertaken that didn't have an obvious structure in terms of O.O.


Advertisement