Please take time to read the code disclaimer.

<--Go back to Kent's Projects

<--Go back to project post

/**
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * WebGUI.java
 *
 * Created on Nov 29, 2011, 8:11:02 PM
 */
package websytem;

import backend.*;
import java.util.*;
import javax.swing.*;
import employeesystem.*;
import silverlining.*;

/**
 *
 * @author Kent
 */
public class WebGUI extends javax.swing.JFrame {

  private AccountGenerator ag;

  /** Creates new form WebGUI
   * @param ag 
   */
  public WebGUI(AccountGenerator ag) {
    this.ag = ag;
    initComponents();
    this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
    myInitComponents();
    StaticClass.centerAndPack(this);
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
    // //GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        myStuffLogo = new javax.swing.JLabel();
        salespersonUtilityLabel = new javax.swing.JLabel();
        currentUserLabel = new javax.swing.JLabel();
        logoutButton = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        logout = new javax.swing.JMenuItem();
        myAccountMenu = new javax.swing.JMenu();
        accountManagement = new javax.swing.JMenuItem();
        userAccountsManagement = new javax.swing.JMenuItem();
        systemUtilitiesMenu = new javax.swing.JMenu();
        printersAndDevices = new javax.swing.JMenuItem();
        backupAndRecovery = new javax.swing.JMenuItem();
        userAccountsSubMenu = new javax.swing.JMenu();
        maintainAccounts = new javax.swing.JMenuItem();
        changeCurrentUserPassword = new javax.swing.JMenuItem();
        userPreferencesMenu = new javax.swing.JMenu();
        dialogStyle = new javax.swing.JMenuItem();
        colorAndFont = new javax.swing.JMenuItem();
        shortcuts = new javax.swing.JMenuItem();
        macroFacility = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentsAndIndex = new javax.swing.JMenuItem();
        searchForHelp = new javax.swing.JMenuItem();
        taskList = new javax.swing.JMenuItem();
        aboutTheMyStuffSystem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SLEEK - Demo Web Design");
        getContentPane().setLayout(new java.awt.GridBagLayout());

        myStuffLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/SilverLiningLogo25%.jpg"))); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.insets = new java.awt.Insets(30, 30, 30, 30);
        getContentPane().add(myStuffLogo, gridBagConstraints);

        salespersonUtilityLabel.setFont(new java.awt.Font("Tahoma", 0, 36));
        salespersonUtilityLabel.setText("Demo Web Design");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.insets = new java.awt.Insets(30, 30, 30, 30);
        getContentPane().add(salespersonUtilityLabel, gridBagConstraints);

        currentUserLabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        currentUserLabel.setText("Current User: DEMO CURRENT USER");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(20, 20, 20, 20);
        getContentPane().add(currentUserLabel, gridBagConstraints);

        logoutButton.setText("Logout");
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LAST_LINE_END;
        gridBagConstraints.insets = new java.awt.Insets(20, 20, 20, 20);
        getContentPane().add(logoutButton, gridBagConstraints);

        fileMenu.setText("File");

        logout.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        logout.setText("Logout");
        logout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutActionPerformed(evt);
            }
        });
        fileMenu.add(logout);

        menuBar.add(fileMenu);

        myAccountMenu.setText("My Account");

        accountManagement.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        accountManagement.setText("Account Management");
        accountManagement.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                accountManagementActionPerformed(evt);
            }
        });
        myAccountMenu.add(accountManagement);

        userAccountsManagement.setText("User Accounts");
        myAccountMenu.add(userAccountsManagement);

        menuBar.add(myAccountMenu);

        systemUtilitiesMenu.setText("System Utilities");

        printersAndDevices.setText("Printers and Devices");
        systemUtilitiesMenu.add(printersAndDevices);

        backupAndRecovery.setText("Backup and Recovery");
        systemUtilitiesMenu.add(backupAndRecovery);

        userAccountsSubMenu.setText("User Accounts");

        maintainAccounts.setText("Maintain Accounts");
        userAccountsSubMenu.add(maintainAccounts);

        changeCurrentUserPassword.setText("Change Current User Password");
        userAccountsSubMenu.add(changeCurrentUserPassword);

        systemUtilitiesMenu.add(userAccountsSubMenu);

        menuBar.add(systemUtilitiesMenu);

        userPreferencesMenu.setText("User Preferences");

        dialogStyle.setText("Dialog Style");
        userPreferencesMenu.add(dialogStyle);

        colorAndFont.setText("Color and Font");
        userPreferencesMenu.add(colorAndFont);

        shortcuts.setText("Shortcuts");
        userPreferencesMenu.add(shortcuts);

        macroFacility.setText("Macro Facility");
        userPreferencesMenu.add(macroFacility);

        menuBar.add(userPreferencesMenu);

        helpMenu.setText("Help");

        contentsAndIndex.setText("Contents and Index");
        helpMenu.add(contentsAndIndex);

        searchForHelp.setText("Search for Help");
        helpMenu.add(searchForHelp);

        taskList.setText("Task List");
        helpMenu.add(taskList);

        aboutTheMyStuffSystem.setText("About the MyStuff System");
        helpMenu.add(aboutTheMyStuffSystem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        pack();
    }// //GEN-END:initComponents

  private void logoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutActionPerformed
    logout();
  }//GEN-LAST:event_logoutActionPerformed

  private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed
    logout();
  }//GEN-LAST:event_logoutButtonActionPerformed

  private void accountManagementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_accountManagementActionPerformed
    AccountsFrame af = new AccountsFrame(ag);
    af.setVisible(true);
  }//GEN-LAST:event_accountManagementActionPerformed

  /**
   * This is components I want to initiate
   */
  public void myInitComponents() {
    LinkedList newAccountsList = new LinkedList();
    for (Account account : ag.getAccountsList()) {
      if (account.getName().equals("ABC Inc.")) {
        newAccountsList.add(account);
      }
    }
    ag.setAccountsList(newAccountsList);
  }
  
  /**
   * This method logs the user out
   */
  public void logout() {
    LoginDialog login = new LoginDialog();
    this.setVisible(false);
    login.setVisible(true);
    this.dispose();
  }

  /**
   * @param args the command line arguments
   */
  public static void main(String args[]) {
    /** Set the Nimbus look and feel */
    //
        /** If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
      for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          javax.swing.UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (ClassNotFoundException ex) {
      java.util.logging.Logger.getLogger(WebGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
      java.util.logging.Logger.getLogger(WebGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
      java.util.logging.Logger.getLogger(WebGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
      java.util.logging.Logger.getLogger(WebGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //

    /** Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {

      public void run() {
        new WebGUI(new AccountGenerator()).setVisible(true);
      }
    });
  }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutTheMyStuffSystem;
    private javax.swing.JMenuItem accountManagement;
    private javax.swing.JMenuItem backupAndRecovery;
    private javax.swing.JMenuItem changeCurrentUserPassword;
    private javax.swing.JMenuItem colorAndFont;
    private javax.swing.JMenuItem contentsAndIndex;
    private javax.swing.JLabel currentUserLabel;
    private javax.swing.JMenuItem dialogStyle;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JMenuItem logout;
    private javax.swing.JButton logoutButton;
    private javax.swing.JMenuItem macroFacility;
    private javax.swing.JMenuItem maintainAccounts;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenu myAccountMenu;
    private javax.swing.JLabel myStuffLogo;
    private javax.swing.JMenuItem printersAndDevices;
    private javax.swing.JLabel salespersonUtilityLabel;
    private javax.swing.JMenuItem searchForHelp;
    private javax.swing.JMenuItem shortcuts;
    private javax.swing.JMenu systemUtilitiesMenu;
    private javax.swing.JMenuItem taskList;
    private javax.swing.JMenuItem userAccountsManagement;
    private javax.swing.JMenu userAccountsSubMenu;
    private javax.swing.JMenu userPreferencesMenu;
    // End of variables declaration//GEN-END:variables
}