Myranda

Untitled

Apr 2nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.61 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package coachtravelling;
  7.  
  8. import javax.swing.JOptionPane;
  9.  
  10. /**
  11.  *
  12.  * @author dl3185j
  13.  */
  14. public class StaffGUI extends javax.swing.JFrame {
  15.  
  16.     SingletonController ctr = SingletonController.getInstance();
  17.    
  18.     public StaffGUI() {
  19.         initComponents();
  20.         this.setLocationRelativeTo(null);
  21.         this.setTitle("Staff GUI");
  22.     }
  23.  
  24.     /**
  25.      * This method is called from within the constructor to initialize the form.
  26.      * WARNING: Do NOT modify this code. The content of this method is always
  27.      * regenerated by the Form Editor.
  28.      */
  29.     @SuppressWarnings("unchecked")
  30.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  31.     private void initComponents() {
  32.  
  33.         jLabel1 = new javax.swing.JLabel();
  34.         btnHome = new javax.swing.JButton();
  35.         btnCreateAccount = new javax.swing.JButton();
  36.         btnAddTrip = new javax.swing.JButton();
  37.         btnReccommendation = new javax.swing.JButton();
  38.  
  39.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  40.  
  41.         jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
  42.         jLabel1.setText("STAFF LOGIN");
  43.  
  44.         btnHome.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/home-icon.png"))); // NOI18N
  45.         btnHome.addActionListener(new java.awt.event.ActionListener() {
  46.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  47.                 btnHomeActionPerformed(evt);
  48.             }
  49.         });
  50.  
  51.         btnCreateAccount.setText("Create Customer Account");
  52.         btnCreateAccount.addActionListener(new java.awt.event.ActionListener() {
  53.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  54.                 btnCreateAccountActionPerformed(evt);
  55.             }
  56.         });
  57.  
  58.         btnAddTrip.setText("Add New Trip");
  59.         btnAddTrip.addActionListener(new java.awt.event.ActionListener() {
  60.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  61.                 btnAddTripActionPerformed(evt);
  62.             }
  63.         });
  64.  
  65.         btnReccommendation.setText("Make reccommendations");
  66.         btnReccommendation.addActionListener(new java.awt.event.ActionListener() {
  67.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  68.                 btnReccommendationActionPerformed(evt);
  69.             }
  70.         });
  71.  
  72.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  73.         getContentPane().setLayout(layout);
  74.         layout.setHorizontalGroup(
  75.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  76.             .addGroup(layout.createSequentialGroup()
  77.                 .addContainerGap()
  78.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  79.                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  80.                         .addComponent(btnReccommendation, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  81.                         .addComponent(btnAddTrip, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE))
  82.                     .addGroup(layout.createSequentialGroup()
  83.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  84.                             .addGroup(layout.createSequentialGroup()
  85.                                 .addComponent(jLabel1)
  86.                                 .addGap(23, 23, 23))
  87.                             .addGroup(layout.createSequentialGroup()
  88.                                 .addComponent(btnCreateAccount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  89.                                 .addGap(18, 18, 18)))
  90.                         .addComponent(btnHome, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
  91.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  92.         );
  93.         layout.setVerticalGroup(
  94.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  95.             .addGroup(layout.createSequentialGroup()
  96.                 .addContainerGap()
  97.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  98.                     .addComponent(jLabel1)
  99.                     .addComponent(btnHome))
  100.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  101.                 .addComponent(btnCreateAccount, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
  102.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  103.                 .addComponent(btnAddTrip, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
  104.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  105.                 .addComponent(btnReccommendation)
  106.                 .addGap(10, 10, 10))
  107.         );
  108.  
  109.         pack();
  110.     }// </editor-fold>                        
  111.  
  112.     private void btnHomeActionPerformed(java.awt.event.ActionEvent evt) {                                        
  113.         //open the main menu
  114.         ctr.openGUI("Main Menu");
  115.         this.setVisible(false);
  116.     }                                      
  117.  
  118.     private void btnAddTripActionPerformed(java.awt.event.ActionEvent evt) {                                          
  119.         //open the add trip gui
  120.         ctr.openGUI("Add Trip");
  121.         this.setVisible(false);
  122.     }                                          
  123.  
  124.     private void btnCreateAccountActionPerformed(java.awt.event.ActionEvent evt) {                                                
  125.         //open the register gui
  126.         ctr.openGUI("Register");
  127.         this.setVisible(false);
  128.     }                                                
  129.  
  130.     private void btnReccommendationActionPerformed(java.awt.event.ActionEvent evt) {                                                  
  131.         //make a reccommendation to a customer
  132.         String reccommendation = ctr.makeReccommendation();
  133.         JOptionPane.showMessageDialog(null, reccommendation);
  134.     }                                                  
  135.  
  136.     /**
  137.      * @param args the command line arguments
  138.      */
  139.     public static void main(String args[]) {
  140.         /* Set the Nimbus look and feel */
  141.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  142.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  143.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  144.          */
  145.         try {
  146.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  147.                 if ("Nimbus".equals(info.getName())) {
  148.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  149.                     break;
  150.                 }
  151.             }
  152.         } catch (ClassNotFoundException ex) {
  153.             java.util.logging.Logger.getLogger(StaffGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  154.         } catch (InstantiationException ex) {
  155.             java.util.logging.Logger.getLogger(StaffGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  156.         } catch (IllegalAccessException ex) {
  157.             java.util.logging.Logger.getLogger(StaffGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  158.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  159.             java.util.logging.Logger.getLogger(StaffGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  160.         }
  161.         //</editor-fold>
  162.  
  163.         /* Create and display the form */
  164.         java.awt.EventQueue.invokeLater(new Runnable() {
  165.             public void run() {
  166.                 new StaffGUI().setVisible(true);
  167.             }
  168.         });
  169.     }
  170.  
  171.     // Variables declaration - do not modify                    
  172.     private javax.swing.JButton btnAddTrip;
  173.     private javax.swing.JButton btnCreateAccount;
  174.     private javax.swing.JButton btnHome;
  175.     private javax.swing.JButton btnReccommendation;
  176.     private javax.swing.JLabel jLabel1;
  177.     // End of variables declaration                  
  178. }
Advertisement
Add Comment
Please, Sign In to add comment