⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workuserdialog.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
//// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
package org.ozoneDB.adminGui.feature.account.users;

import java.awt.BorderLayout;
import javax.swing.JDialog;

import org.ozoneDB.adminGui.widget.ButtonPanel;
import org.ozoneDB.adminGui.widget.ButtonPanelListener;
import org.ozoneDB.adminGui.main.AdminGui;


//#############################################################################
/**
 * This class gets a new account name to be created.
 *
 * @author  <p align=center>Ibsen Ramos-Bonilla
 * <br>Copyright &copy 1997-@year@ by SMB GmbH. All Rights Reserved.</p>
 *
 * @version 1.0
 */
//#############################################################################

public class WorkUserDialog extends JDialog implements ButtonPanelListener {

    /** Handle to the parent UserAccount object. */
    private UserAccount parent = null;
    /** Panel used to get the account name and password. */
    private WorkUserPanel userPane = null;
    /** List of buttons for the button panel. */
    private String[] button = {"OK", "Cancel"};
    /** Flag to monitor if the ok buttons was clicked. */
    private boolean ok = false;
    /** The account name. */
    private String name = "";
    /** The account password. */
    private String password = "";


    /**
     * Constructor creates the add account dialog.
     */
    public WorkUserDialog(UserAccount parent) {
        super(AdminGui.instance(), "Create User", true);
        this.parent = parent;

        try {
            init();
            this.setSize(300, 200);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * This method initializes the dialog.
     */
    private void init() throws Exception {
        //set dialog attributes
        this.setResizable(false);
        this.setLocationRelativeTo(AdminGui.instance());
        this.getContentPane().setLayout(new BorderLayout());

        //create panels
        userPane = new WorkUserPanel();

        ButtonPanel buttonPane = new ButtonPanel(this.button);
        buttonPane.addConnectionListener(this);

        //add the dialog components
        this.getContentPane().add(userPane, BorderLayout.CENTER);
        this.getContentPane().add(buttonPane, BorderLayout.SOUTH);
    }

    /**
     * This method handles the button clicks..
     *
     * @param buttonName - name of the button pressed.
     */
    public void buttonExecute(String buttonName) {
        //ok
        if (button[0].equals(buttonName))
            collectUserInfo();

        //cancel
        else
            this.hide();
    }

    /**
     * This method is called when the ok button is clicked.
     */
    private void collectUserInfo() {
        this.name = this.userPane.getUserName().trim();
        this.password = this.userPane.getUserPassword().trim();

        //verify that we have a valid entry
        if (this.name.equals("") | this.name == null)
            this.ok = false;
        else {
            this.ok = true;

            //check password
            if (this.password.equals("") | this.password == null)
                this.password = name;
        }

        this.hide();
    }

    /**
     * This method returns the account name.
     *
     * @return String - the new account name.
     */
    public String getName() {
        return this.name;
    }

    /**
     * This method returns the account password.
     *
     * @return String - the new account password.
     */
    public String getPassword() {
        return this.password;
    }

    /**
     * This method denotes if the ok button was pushed.
     *
     * @return boolean - TRUE = OK button pushed.
     *                   FALSE = Cancel button pushed.
     */
    public boolean isOK() {
        return this.ok;
    }

} //--------------------------------- E O F -----------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -