0

I'm working on my 2nd year Project and I need your help. I want to create a DIY Store System that will contain multiple windows. All the screens are done, just need the idea how they will be managed all together There is a login window with the company logo, address, textfields etc that will pop up when the system is started. Then the tricky part begins, there are 3 types of users (admin, sales and stock user) and every one of them will have a different main menu(GUI).

Any ideas how to deal with this problem?

  • 7
    See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice) – Reimeus Apr 01 '13 at 20:11
  • You can have multiple menu systems intended for the same frame at the same time. The only limitation that just one of them can be active at any given moment. – PM 77-1 Apr 01 '13 at 20:19
  • thanks, how do I achieve that? 3 constructors in the mainGUI.java file? Do I have to use JFrame for the mainGui and JDialog for the rest, login and other windows? – user2233446 Apr 01 '13 at 20:24

2 Answers2

2

suggest you use objects on the user account to determine which panel to display i.e

admin gets an admin panel which extends from Jpanel (and maybe a base panel all user panels share/extend) then you would check to see which user account is logging in and load the correct panel or portions of a panel, re use as much of the gui panels as possible to cut down on the amount of code bulk. this might help later on as if you are working with the panels and user groups you could do is instance of...

               Jpanel
                 |
         some base gui panel
        |           |           |
adminPanel  salesPanel    userPanel
Andy B
  • 328
  • 3
  • 9
  • thanks for your answer. Can I use the same idea with JFrame objects? I would have 3 systems JFrames, one for each user. The base JFrame would have an empty JFrame with JFrame object of the appropriate user passed into its constructor. I can start my system by calling a JDialog Login Window. How does it look? – user2233446 Apr 01 '13 at 23:38
  • 1
    *"Can I use the same idea with JFrame objects?"* As soon as you have 2 or more frames, the code has gone wrong. This probably needs 1 frame, 1 CardLayout or tabbed pane, and 3 panels, none of which extend panel. – Andrew Thompson Apr 02 '13 at 00:19
  • agree with andrew thompson you should really only have one frame inside that frame is where you will have your other panels. – Andy B Apr 02 '13 at 13:21
  • you would def have your main jframe start up when the application is started, then user dialog popup for credentials, then load the user group panels i am loathed to give any more specific design specifications as this is your project, if you ask a more detailed technical question i would be happy to answer it. see [jframe](http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html) [jpanel](http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html) – Andy B Apr 02 '13 at 13:28
0
Here is my idea for this:
to create a MainGUI.java file (JFrame) that contains
3 constructors(+ default constr) with separate GUI for each user. In the main method
I would call a login object(JDialog) and check what type of user
I'm dealing with and then create an appropriate mainGUI
object.    

(pseudo code) Please comment.

    class mainGUI
    //variables
    public mainGui() // default constructor
    //body
    public mainGUI(var1, var2, va3) // type1 user constructor
    //body
    public mainGUI(var1, var3, var2) // type2 user constructor
    //body
    public mainGUI(var2, var1. var3) //type3 user constructor

    main method()
    mainGui m = new mainGUI();
    Login l1 = new Login(m);
    if(l1.getPassword() == some array value) // type1 User passwords are stored in Array1 (eg. Admin)
    then
    mainGUI m1 = new mainGUI(var1, var2, var3); // creates appropriate user gui
    else if(l1.getPassword() == some array value ) // user type2 (e.g. Sales Staff)
    then
    mainGUI m1 = new mainGUI(var1, var3, var2);
    and so on...