简体   繁体   English

如何管理多个Windows系统 - Java(Swing)

[英]How to manage multiple windows system - Java(Swing)

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. 我想创建一个包含多个窗口的DIY商店系统。 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). 然后棘手的部分开始,有3种类型的用户(管理员,销售和股票用户),每个用户将有一个不同的主菜单(GUI)。

Any ideas how to deal with this problem? 任何想法如何处理这个问题?

suggest you use objects on the user account to determine which panel to display ie 建议您使用用户帐户上的对象来确定要显示的面板,即

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. admin获取一个管理面板,该面板从Jpanel扩展(可能是所有用户面板共享/扩展的基础面板)然后您将检查登录哪个用户帐户并加载正确的面板或面板的某些部分,重新​​使用gui面板尽可能减少代码量。 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
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...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM