Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.view; import com.controller.CAdmin; import com.controller.CChangePassword; import com.mashape.unirest.http.exceptions.UnirestException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JPasswordField; import static javax.swing.JOptionPane.showMessageDialog; import org.json.JSONException; /** * * @author csavas */ public class AdminWindow extends javax.swing.JFrame { /** * Creates new form AdminWIndow */ public AdminWindow() { initComponents(); } /** * 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") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jTabbedPane1 = new javax.swing.JTabbedPane(); AddPortfMan = new javax.swing.JPanel(); CreatePMButton = new java.awt.Button(); CreatePortfolioNameText = new javax.swing.JTextField(); CreatePortfolioUsernameText = new javax.swing.JTextField(); CreatePortfolioPasswordText = new JPasswordField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); label4 = new java.awt.Label(); jLabel4 = new javax.swing.JLabel(); CreatePortfolioConfirmPasswordText = new JPasswordField(); AddTrader = new javax.swing.JPanel(); createTraderButton = new java.awt.Button(); CreateTraderNameText = new javax.swing.JTextField(); CreateTraderUsernameText = new javax.swing.JTextField(); CreateTraderPasswordText = new JPasswordField(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); label5 = new java.awt.Label(); CreateTraderConfirmPasswordText = new JPasswordField(); jLabel5 = new javax.swing.JLabel(); AddBroker = new javax.swing.JPanel(); createBrokerButton = new java.awt.Button(); CreateBrokerNameText = new javax.swing.JTextField(); CreateBrokerEmailText = new javax.swing.JTextField(); jLabel13 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); jPanel4 = new javax.swing.JPanel(); label6 = new java.awt.Label(); ChangePassword = new javax.swing.JPanel(); label2 = new java.awt.Label(); label3 = new java.awt.Label(); label7 = new java.awt.Label(); submitButton = new java.awt.Button(); jPanel5 = new javax.swing.JPanel(); label8 = new java.awt.Label(); NewPassText = new JPasswordField(); ConfirmPassText = new JPasswordField(); OldPassText = new JPasswordField(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(new java.awt.GridBagLayout()); CreatePMButton.setBackground(new java.awt.Color(51, 51, 51)); CreatePMButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N CreatePMButton.setForeground(new java.awt.Color(240, 240, 240)); CreatePMButton.setLabel("Create Portfolio Manager"); CreatePMButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CreatePMButtonActionPerformed(evt); } }); CreatePortfolioNameText.setBackground(new java.awt.Color(51, 51, 51)); CreatePortfolioNameText.setForeground(new java.awt.Color(255, 255, 255)); CreatePortfolioNameText.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CreatePortfolioNameTextActionPerformed(evt); } }); CreatePortfolioUsernameText.setBackground(new java.awt.Color(51, 51, 51)); CreatePortfolioUsernameText.setForeground(new java.awt.Color(255, 255, 255)); CreatePortfolioPasswordText.setBackground(new java.awt.Color(51, 51, 51)); CreatePortfolioPasswordText.setForeground(new java.awt.Color(255, 255, 255)); jLabel1.setText("Name:"); jLabel2.setText("Username:"); jLabel3.setText("Temporary Password:"); jPanel2.setBackground(new java.awt.Color(51, 51, 51)); label4.setAlignment(java.awt.Label.CENTER); label4.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N label4.setForeground(new java.awt.Color(240, 240, 240)); label4.setText("Create A New Portfolio Manager"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addGap(41, 41, 41) .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(51, Short.MAX_VALUE)))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 52, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))); jLabel4.setText("Confirm Password:"); CreatePortfolioConfirmPasswordText.setBackground(new java.awt.Color(51, 51, 51)); CreatePortfolioConfirmPasswordText.setForeground(new java.awt.Color(255, 255, 255)); javax.swing.GroupLayout AddPortfManLayout = new javax.swing.GroupLayout(AddPortfMan); AddPortfMan.setLayout(AddPortfManLayout); AddPortfManLayout.setHorizontalGroup(AddPortfManLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(AddPortfManLayout.createSequentialGroup().addGap(42, 42, 42) .addGroup(AddPortfManLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(AddPortfManLayout.createSequentialGroup().addGroup(AddPortfManLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(CreatePortfolioConfirmPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE) .addComponent( CreatePMButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(AddPortfManLayout.createSequentialGroup().addGroup(AddPortfManLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(AddPortfManLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(CreatePortfolioPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(AddPortfManLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel2).addComponent(CreatePortfolioUsernameText)) .addComponent(jLabel1).addComponent(CreatePortfolioNameText, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); AddPortfManLayout.setVerticalGroup(AddPortfManLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(AddPortfManLayout.createSequentialGroup().addContainerGap() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CreatePortfolioNameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CreatePortfolioUsernameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CreatePortfolioPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(AddPortfManLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(AddPortfManLayout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(CreatePMButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addGroup(AddPortfManLayout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CreatePortfolioConfirmPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(44, Short.MAX_VALUE))))); jTabbedPane1.addTab("Add Portfolio Manager", AddPortfMan); createTraderButton.setBackground(new java.awt.Color(51, 51, 51)); createTraderButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N createTraderButton.setForeground(new java.awt.Color(240, 240, 240)); createTraderButton.setLabel("Create Trader"); createTraderButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { createTraderButtonActionPerformed(evt); } }); CreateTraderNameText.setBackground(new java.awt.Color(51, 51, 51)); CreateTraderNameText.setForeground(new java.awt.Color(255, 255, 255)); CreateTraderUsernameText.setBackground(new java.awt.Color(51, 51, 51)); CreateTraderUsernameText.setForeground(new java.awt.Color(255, 255, 255)); CreateTraderPasswordText.setBackground(new java.awt.Color(51, 51, 51)); CreateTraderPasswordText.setForeground(new java.awt.Color(255, 255, 255)); jLabel9.setText("Name:"); jLabel10.setText("Username:"); jLabel11.setText("Temporary Password:"); jPanel3.setBackground(new java.awt.Color(51, 51, 51)); label5.setAlignment(java.awt.Label.CENTER); label5.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N label5.setForeground(new java.awt.Color(240, 240, 240)); label5.setText("Create A New Trader"); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(41, 41, 41) .addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(51, Short.MAX_VALUE)))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 52, Short.MAX_VALUE) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))); CreateTraderConfirmPasswordText.setBackground(new java.awt.Color(51, 51, 51)); CreateTraderConfirmPasswordText.setForeground(new java.awt.Color(255, 255, 255)); jLabel5.setText("Confirm Password:"); javax.swing.GroupLayout AddTraderLayout = new javax.swing.GroupLayout(AddTrader); AddTrader.setLayout(AddTraderLayout); AddTraderLayout.setHorizontalGroup(AddTraderLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(AddTraderLayout.createSequentialGroup().addGap(42, 42, 42) .addGroup(AddTraderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel9) .addComponent(CreateTraderNameText, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(AddTraderLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel10).addComponent(CreateTraderUsernameText)) .addGroup(AddTraderLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(CreateTraderPasswordText)) .addGroup(AddTraderLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(CreateTraderConfirmPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(228, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, AddTraderLayout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(createTraderButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(50, 50, 50))); AddTraderLayout.setVerticalGroup(AddTraderLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(AddTraderLayout.createSequentialGroup().addContainerGap() .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(jLabel9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CreateTraderNameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel10).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CreateTraderUsernameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel11).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CreateTraderPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CreateTraderConfirmPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(createTraderButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); jTabbedPane1.addTab("Add Trader", AddTrader); createBrokerButton.setBackground(new java.awt.Color(51, 51, 51)); createBrokerButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N createBrokerButton.setForeground(new java.awt.Color(240, 240, 240)); createBrokerButton.setLabel("Create Broker"); createBrokerButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { createBrokerButtonActionPerformed(evt); } }); CreateBrokerNameText.setBackground(new java.awt.Color(51, 51, 51)); CreateBrokerNameText.setForeground(new java.awt.Color(255, 255, 255)); CreateBrokerEmailText.setBackground(new java.awt.Color(51, 51, 51)); CreateBrokerEmailText.setForeground(new java.awt.Color(255, 255, 255)); jLabel13.setText("Name:"); jLabel14.setText("Email Address:"); jPanel4.setBackground(new java.awt.Color(51, 51, 51)); label6.setAlignment(java.awt.Label.CENTER); label6.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N label6.setForeground(new java.awt.Color(240, 240, 240)); label6.setText("Create A New Broker"); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addGap(41, 41, 41) .addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(51, Short.MAX_VALUE)))); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 52, Short.MAX_VALUE) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap() .addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))); javax.swing.GroupLayout AddBrokerLayout = new javax.swing.GroupLayout(AddBroker); AddBroker.setLayout(AddBrokerLayout); AddBrokerLayout.setHorizontalGroup(AddBrokerLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(AddBrokerLayout.createSequentialGroup().addGroup(AddBrokerLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(AddBrokerLayout.createSequentialGroup().addGap(149, 149, 149) .addGroup(AddBrokerLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel14).addComponent(jLabel13) .addComponent(CreateBrokerNameText, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE) .addComponent(CreateBrokerEmailText)) .addGap(0, 127, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, AddBrokerLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent( createBrokerButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); AddBrokerLayout.setVerticalGroup(AddBrokerLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(AddBrokerLayout.createSequentialGroup().addContainerGap() .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(76, 76, 76).addComponent(jLabel13).addGap(7, 7, 7) .addComponent(CreateBrokerNameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(jLabel14) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CreateBrokerEmailText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(createBrokerButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); jTabbedPane1.addTab("Add Broker", AddBroker); label2.setText("Old Password:"); label3.setText("New Password:"); label7.setText("Confirm Password:"); submitButton.setBackground(new java.awt.Color(51, 51, 51)); submitButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N submitButton.setForeground(new java.awt.Color(240, 240, 240)); submitButton.setLabel("Submit"); submitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { submitButtonActionPerformed(evt); } }); jPanel5.setBackground(new java.awt.Color(51, 51, 51)); label8.setAlignment(java.awt.Label.CENTER); label8.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N label8.setForeground(new java.awt.Color(240, 240, 240)); label8.setText("Change Password"); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup(jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addGap(41, 41, 41) .addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap() .addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); NewPassText.setBackground(new java.awt.Color(51, 51, 51)); NewPassText.setForeground(new java.awt.Color(255, 255, 255)); ConfirmPassText.setBackground(new java.awt.Color(51, 51, 51)); ConfirmPassText.setForeground(new java.awt.Color(255, 255, 255)); OldPassText.setBackground(new java.awt.Color(51, 51, 51)); OldPassText.setForeground(new java.awt.Color(255, 255, 255)); javax.swing.GroupLayout ChangePasswordLayout = new javax.swing.GroupLayout(ChangePassword); ChangePassword.setLayout(ChangePasswordLayout); ChangePasswordLayout.setHorizontalGroup(ChangePasswordLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(ChangePasswordLayout.createSequentialGroup().addGap(72, 72, 72) .addGroup(ChangePasswordLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(submitButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(ChangePasswordLayout.createSequentialGroup() .addGroup(ChangePasswordLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(ChangePasswordLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(NewPassText) .addGroup(ChangePasswordLayout.createSequentialGroup() .addComponent(ConfirmPassText, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 1, Short.MAX_VALUE)) .addComponent(OldPassText)))) .addContainerGap(77, Short.MAX_VALUE))); ChangePasswordLayout.setVerticalGroup(ChangePasswordLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ChangePasswordLayout.createSequentialGroup().addContainerGap() .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(27, 27, 27) .addGroup( ChangePasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(OldPassText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( ChangePasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(NewPassText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( ChangePasswordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ConfirmPassText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(34, 34, 34) .addComponent(submitButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(74, Short.MAX_VALUE))); jTabbedPane1.addTab("Change Password", ChangePassword); getContentPane().add(jTabbedPane1, new java.awt.GridBagConstraints()); pack(); }// </editor-fold>//GEN-END:initComponents private void CreatePMButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CreatePMButtonActionPerformed String nameText = CreatePortfolioNameText.getText(); String usernameText = CreatePortfolioUsernameText.getText(); String passwordText = CreatePortfolioPasswordText.getText(); String confirmPasswordText = CreatePortfolioConfirmPasswordText.getText(); boolean emptyTrigg = false; //SEND TO CONTROLLER TO CREATE PM AND SEND TO DB if (passwordText.equals(confirmPasswordText)) { if (nameText.trim().equals("") || usernameText.trim().equals("") || passwordText.trim().equals("") || confirmPasswordText.trim().equals("")) { showMessageDialog(null, "None of the fields should be empty if you wish to create a Portfolio Manager."); emptyTrigg = true; } if (emptyTrigg == false) { CAdmin.addPortfolioManager(nameText, usernameText, passwordText); CreatePortfolioNameText.setText(""); CreatePortfolioUsernameText.setText(""); CreatePortfolioPasswordText.setText(""); CreatePortfolioConfirmPasswordText.setText(""); } } else { showMessageDialog(null, "Please check that the password you entered matches what you entered in the confirm password field."); } }//GEN-LAST:event_CreatePMButtonActionPerformed private void createTraderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createTraderButtonActionPerformed String nameText = CreateTraderNameText.getText(); String usernameText = CreateTraderUsernameText.getText(); String passwordText = CreateTraderPasswordText.getText(); String confirmPasswordText = CreateTraderConfirmPasswordText.getText(); //SEND TO CONTROLLER TO CREATE TRADER AND SEND TO DB if (passwordText.equals(confirmPasswordText)) { boolean emptyTrigg = false; //SEND TO CONTROLLER TO CREATE PM AND SEND TO DB if (passwordText.equals(confirmPasswordText)) { if (nameText.trim().equals("") || usernameText.trim().equals("") || passwordText.trim().equals("") || confirmPasswordText.trim().equals("")) { showMessageDialog(null, "None of the fields should be empty if you wish to create a Trader."); emptyTrigg = true; } if (emptyTrigg == false) { CAdmin.addTrader(nameText, usernameText, passwordText); CreateTraderNameText.setText(""); CreateTraderUsernameText.setText(""); CreateTraderPasswordText.setText(""); CreateTraderConfirmPasswordText.setText(""); } } else { showMessageDialog(null, "Please check that the password you entered matches what you entered in the confirm password field."); } } }//GEN-LAST:event_createTraderButtonActionPerformed private void createBrokerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createBrokerButtonActionPerformed String nameText = CreateBrokerNameText.getText(); String usernameText = CreateBrokerEmailText.getText(); //SEND TO CONTROLLER TO CREATE BROKER AND SEND TO DB try { boolean emptyTrigg = false; if (nameText.trim().equals("") || usernameText.trim().equals("")) { showMessageDialog(null, "None of the fields should be empty if you wish to create a Broker."); emptyTrigg = true; } if (emptyTrigg == false) { CAdmin.addBroker(nameText, usernameText); CreateBrokerNameText.setText(""); CreateBrokerEmailText.setText(""); } } catch (UnirestException e) { System.err.println("Unirest Exception in the View: " + e.getMessage()); } }//GEN-LAST:event_createBrokerButtonActionPerformed private void CreatePortfolioNameTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CreatePortfolioNameTextActionPerformed // TODO add your handling code here: }//GEN-LAST:event_CreatePortfolioNameTextActionPerformed private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submitButtonActionPerformed //ADD FIELDS String oldPassText = OldPassText.getText(); String newPassText = NewPassText.getText(); String confirmPassText = ConfirmPassText.getText(); try { //GET THE OLD PASSWORD OF USER HERE boolean emptyTrigg = false; //SEND TO CONTROLLER TO CREATE PM AND SEND TO DB if (newPassText.trim().equals("") || confirmPassText.trim().equals("")) { showMessageDialog(null, "None of the fields should be empty if you wish to create Portfolio Manager."); emptyTrigg = true; } if (emptyTrigg == false) { CChangePassword.handleChange(oldPassText, newPassText, confirmPassText); OldPassText.setText(""); NewPassText.setText(""); ConfirmPassText.setText(""); } } catch (JSONException | UnirestException ex) { Logger.getLogger(AdminWindow.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_submitButtonActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* 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 { javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel"); /*for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } }*/ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(AdminWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new AdminWindow().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel AddBroker; private javax.swing.JPanel AddPortfMan; private javax.swing.JPanel AddTrader; private javax.swing.JPanel ChangePassword; private javax.swing.JTextField ConfirmPassText; private javax.swing.JTextField CreateBrokerEmailText; private javax.swing.JTextField CreateBrokerNameText; private java.awt.Button CreatePMButton; private javax.swing.JTextField CreatePortfolioConfirmPasswordText; private javax.swing.JTextField CreatePortfolioNameText; private javax.swing.JTextField CreatePortfolioPasswordText; private javax.swing.JTextField CreatePortfolioUsernameText; private javax.swing.JTextField CreateTraderConfirmPasswordText; private javax.swing.JTextField CreateTraderNameText; private javax.swing.JTextField CreateTraderPasswordText; private javax.swing.JTextField CreateTraderUsernameText; private javax.swing.JTextField NewPassText; private javax.swing.JTextField OldPassText; private java.awt.Button createBrokerButton; private java.awt.Button createTraderButton; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JTabbedPane jTabbedPane1; private java.awt.Label label2; private java.awt.Label label3; private java.awt.Label label4; private java.awt.Label label5; private java.awt.Label label6; private java.awt.Label label7; private java.awt.Label label8; private java.awt.Button submitButton; // End of variables declaration//GEN-END:variables }