com.farouk.projectapp.FirstGUI.java Source code

Java tutorial

Introduction

Here is the source code for com.farouk.projectapp.FirstGUI.java

Source

/*
 * 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.farouk.projectapp;

import java.awt.Color;
import java.awt.Component;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Date;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.xy.XYDataset;

/**
 *
 * @author farou_000
 */
public class FirstGUI extends javax.swing.JFrame {

    /**
     * Creates new form FirstGUI
     */
    public FirstGUI() {

        initComponents();

        checkLoginState(loginState);
    }

    /**
     * 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();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        DefaultTableModel a = new DefaultTableModel();
        jTable2 = new javax.swing.JTable() {
            public boolean isCellEditable(int d, int c) {
                return false;
            }

            @Override
            public Component prepareRenderer(TableCellRenderer renderer, int row, int col) {
                Component comp = super.prepareRenderer(renderer, row, col);
                String value = getModel().getValueAt(row, 0).toString();
                int a = SQLConnect.ifReported(userID, value);
                if (a == 1) {
                    comp.setBackground(Color.red);
                } else {
                    comp.setBackground(Color.white);
                    comp.setForeground(Color.black);
                }

                return comp;
            }
        };
        jButton5 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jButton10 = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jPanel15 = new javax.swing.JPanel();
        jPanel16 = new javax.swing.JPanel();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jPanel10 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jEditorPane1 = new javax.swing.JEditorPane();
        jButton15 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jTextField4 = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable() {
            public boolean isCellEditable(int d, int c) {
                return false;
            }
        };
        jButton6 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        DefaultListModel modelCompaniesName = new DefaultListModel();
        try {
            for (String p : SQLConnect.getAllCompaniesNames()) {
                modelCompaniesName.addElement(p);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        jList1 = new javax.swing.JList();
        jLabel3 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jButton8 = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jTextField2 = new javax.swing.JTextField();
        jPasswordField1 = new javax.swing.JPasswordField();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jButton17 = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        jButton18 = new javax.swing.JButton();
        jTextField3 = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTabbedPane1.setToolTipText("");
        jTabbedPane1.setMinimumSize(new java.awt.Dimension(150, 200));
        jTabbedPane1.setPreferredSize(new java.awt.Dimension(200, 200));

        jScrollPane1.setViewportView(jTable2);
        jTable2.setModel(a);
        try {
            UpdatejTable2();
        } catch (Exception e) {
            e.printStackTrace();
        }
        jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable2MouseClicked(evt);
            }
        });
        jTable2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTable2KeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(jTable2);

        jButton5.setText("Refresh My Portfolio");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel4.setText("   Last Refreshed : ");

        jButton10.setText("Refresh Company");
        jButton10.setVisible(false);
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jLabel10.setText("Total is : " + String.valueOf(total.doubleValue()) + "");

        jTextField6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField6ActionPerformed(evt);
            }
        });
        jTextField6.setVisible(false);

        jTextField7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField7ActionPerformed(evt);
            }
        });

        jLabel14.setText("N of Actions");

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(jPanel16Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel16Layout.createSequentialGroup()
                        .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel16Layout.createSequentialGroup()
                                        .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 42,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(34, 34, 34).addComponent(jTextField6,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jLabel14))
                        .addGap(0, 3, Short.MAX_VALUE)));
        jPanel16Layout.setVerticalGroup(jPanel16Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(13, 13, 13)));

        jButton13.setText("Buy");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jButton14.setText("Sell");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout
                .setHorizontalGroup(
                        jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel15Layout.createSequentialGroup().addComponent(jButton13)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jButton14).addGap(166, 166, 166))
                                .addGroup(jPanel15Layout.createSequentialGroup()
                                        .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel15Layout
                .setVerticalGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel15Layout.createSequentialGroup()
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, 58,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel15Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jButton14).addComponent(jButton13))));

        jButton7.setText("Get News !");
        jButton7.setVisible(false);
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton3.setText("Report");
        jButton3.setVisible(false);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jPanel10.setVisible(false);

        jScrollPane2.setViewportView(jEditorPane1);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
                jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                        jPanel10Layout.createSequentialGroup().addGap(39, 39, 39).addComponent(jScrollPane2,
                                javax.swing.GroupLayout.DEFAULT_SIZE, 423, Short.MAX_VALUE)));
        jPanel10Layout.setVerticalGroup(jPanel10Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel10Layout
                        .createSequentialGroup().addContainerGap().addComponent(jScrollPane2).addContainerGap()));

        jButton15.setText("Automate");
        jButton15.setVisible(false);
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });

        jButton19.setText("Alert");
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });

        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(jPanel6Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap().addGroup(jPanel6Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1)
                        .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, 131,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jButton19, javax.swing.GroupLayout.Alignment.LEADING,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jButton15, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel6Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jButton3).addComponent(jTextField4,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 68,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGroup(jPanel6Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel6Layout.createSequentialGroup()
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jPanel10, 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)
                                                .addGroup(jPanel6Layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                                jPanel6Layout.createSequentialGroup()
                                                                        .addGroup(jPanel6Layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.TRAILING)
                                                                                .addComponent(jLabel10)
                                                                                .addComponent(jButton10))
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                        .addGroup(jPanel6Layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addComponent(jButton5)
                                                                                .addComponent(jLabel4)))
                                                        .addComponent(jLabel5,
                                                                javax.swing.GroupLayout.Alignment.TRAILING,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 157,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGroup(jPanel6Layout.createSequentialGroup().addGap(70, 70, 70)
                                                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        419, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(0, 0, Short.MAX_VALUE)))))
                        .addContainerGap()));

        jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
                new java.awt.Component[] { jButton3, jTextField4 });

        jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 249,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jButton7)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel6Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jButton15).addComponent(jButton3))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel6Layout
                                                .createParallelGroup(
                                                        javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jButton19)
                                                .addGroup(jPanel6Layout.createSequentialGroup().addGap(1, 1, 1)
                                                        .addComponent(jTextField4)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(9, 9, 9))
                                .addGroup(jPanel6Layout.createSequentialGroup()
                                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel6Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addGroup(jPanel6Layout.createSequentialGroup()
                                                        .addGroup(jPanel6Layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(jButton5).addComponent(jButton10))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(jPanel6Layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(jLabel4).addComponent(jLabel10))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(jLabel5,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 24,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(0, 0, Short.MAX_VALUE)))
                                        .addContainerGap()))));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(jPanel5Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(jPanel6,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));
        jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(jPanel6,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));

        jTabbedPane1.addTab("    My Portfolio    ", jPanel5);

        jTextField1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jButton1.setText("Search");
        jButton1.setAlignmentY(0.3F);
        jButton1.setAutoscrolls(true);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Clear");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(jPanel3Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addGap(2, 2, 2)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 82,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18).addComponent(jButton2)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton2))
                        .addContainerGap()));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 145,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(51, 51, 51)));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField1).addComponent(jPanel3,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE))
                        .addContainerGap()));

        jLabel1.setText("Name of Company to look for : ");

        jTable3.setModel(a);
        jScrollPane5.setViewportView(jTable3);
        jScrollPane5.setVisible(false);

        jButton6.setText("Refresh Company");
        jButton6.setVisible(false);
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jLabel2.setText(null);
        jLabel2.setVisible(false);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(jPanel4Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addGroup(jPanel4Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane5)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel4Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                        .addGroup(jPanel4Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel2).addComponent(jButton6))))
                        .addContainerGap()));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel4Layout.createSequentialGroup().addGap(5, 5, 5).addComponent(jButton6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(19, 19, 19)));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jPanel4,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                        .addGroup(jPanel1Layout.createSequentialGroup().addGap(82, 82, 82)
                                .addGroup(jPanel1Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel1).addComponent(jSeparator1,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 598,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(0, 236, Short.MAX_VALUE)))
                        .addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addGap(36, 36, 36).addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 16,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(210, Short.MAX_VALUE)));

        jTabbedPane1.addTab("    Search    ", jPanel1);

        jList1.setModel(modelCompaniesName);
        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList1MouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jList1);

        jLabel3.setText("  List of Companies (NASDAQ)");

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout
                .setHorizontalGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addGroup(jPanel8Layout.createSequentialGroup().addComponent(jLabel3).addGap(0, 50,
                                Short.MAX_VALUE)));
        jPanel8Layout.setVerticalGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel8Layout.createSequentialGroup().addGap(5, 5, 5).addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                                        jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 613, Short.MAX_VALUE)));

        jButton4.setText("Refresh All");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton9.setVisible(false);
        jButton9.setText("Quit");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jLabel9.setText("All prices are in .");

        jLabel8.setVisible(false);

        jButton8.setText("Stop");
        jButton8.setVisible(false);

        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });

        jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordField1ActionPerformed(evt);
            }
        });

        jButton11.setText("Log in");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jButton12.setText("Create account");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout
                .setHorizontalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel7Layout.createSequentialGroup()
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 150,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 138,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel7Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 97,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addContainerGap()));

        jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
                new java.awt.Component[] { jPasswordField1, jTextField2 });

        jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
                new java.awt.Component[] { jButton11, jButton12 });

        jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton12).addContainerGap()));

        jPanel7Layout.linkSize(javax.swing.SwingConstants.VERTICAL,
                new java.awt.Component[] { jPasswordField1, jTextField2 });

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 17)); // NOI18N

        jButton17.setText("Log out");
        jButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton17ActionPerformed(evt);
            }
        });

        jButton18.setText("Change Limit");
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });

        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        jPanel9.setVisible(false);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(jPanel9Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                        .addContainerGap(18, Short.MAX_VALUE)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel9Layout.createSequentialGroup()
                                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jButton18))
                                .addGroup(jPanel9Layout.createSequentialGroup()
                                        .addGroup(jPanel9Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                        jPanel9Layout.createSequentialGroup().addComponent(jLabel11)
                                                                .addGap(30, 30, 30))
                                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                        jPanel9Layout.createSequentialGroup().addComponent(jLabel12)
                                                                .addGap(18, 18, 18)))
                                        .addComponent(jButton17)))
                        .addGap(36, 36, 36)));
        jPanel9Layout.setVerticalGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel9Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel9Layout.createSequentialGroup().addComponent(jLabel11)
                                        .addGap(18, 18, 18).addComponent(jLabel12))
                                .addComponent(jButton17))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(
                                jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jButton18).addGroup(jPanel9Layout.createSequentialGroup()
                                                .addGap(1, 1, 1).addComponent(jTextField3)))
                        .addContainerGap()));

        jLabel6.setVisible(false);

        jMenu1.setText("File");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q,
                java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText("Quit");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Help");

        jMenuItem2.setText("About");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem2);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createSequentialGroup().addComponent(jButton4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton8)))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup().addGroup(layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                                .addComponent(jLabel6)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel8).addGap(85, 85, 85).addComponent(jLabel7)
                                                .addGap(77, 77, 77).addComponent(jButton9))
                                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 931,
                                                Short.MAX_VALUE)
                                        .addGroup(layout.createSequentialGroup().addComponent(jLabel9)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(53, 53, 53).addComponent(jPanel7,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(18, 18, 18))
                                .addGroup(layout.createSequentialGroup().addComponent(jLabel15)
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        layout.createSequentialGroup()
                                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jButton9).addComponent(jButton4).addComponent(jLabel8)
                                        .addComponent(jButton8).addComponent(jLabel6).addComponent(jLabel7))
                                .addContainerGap())
                .addGroup(layout.createSequentialGroup().addGap(16, 16, 16).addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup().addGap(68, 68, 68)
                                                .addComponent(jLabel9))
                                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 515,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel15)
                        .addGap(0, 0, Short.MAX_VALUE)));

        jTabbedPane1.getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
        jTable2.clearSelection();
        jTextField1.setText(jList1.getSelectedValue().toString());
        jScrollPane5.setVisible(true);
        String companyName = jTextField1.getText();
        jLabel15.setText(
                "Selected company : '" + companyName + "'.   " + SQLConnect.checkIfAutomated(userID, companyName));
        StringThirdParty = companyName;
        if (evt.getClickCount() == 2 && jTabbedPane1.getSelectedIndex() == 0
                || jTabbedPane1.getSelectedIndex() == 1) {
            jTabbedPane1.setSelectedIndex(1);
            jLabel15.setText("Selected company : '" + companyName + "'.");
            try {
                SQLConnect.refreshOneCompanyOnlyAtSearch(companyName);
                if (companyName.isEmpty()) {
                    JOptionPane.showMessageDialog(rootPane, "Please provide a valid input.", "Bad input", WIDTH);
                } else {
                    Company com = SQLConnect.lookForCompany(companyName, userID);
                    UpdatejTable3(com);
                    jButton6.setVisible(true);

                }
            } catch (Exception e) {
                System.err.println("Problem in button.\n" + e);
            }
            jLabel2.setVisible(false);
        }
        if (evt.getClickCount() == 1 && jTabbedPane1.getSelectedIndex() == 0) {
            jButton10.setVisible(false);
            jButton7.setVisible(false);
            jButton15.setVisible(false);
            jButton3.setVisible(false);
            jScrollPane2.setVisible(false);
            if (SQLConnect.ifAutomated(userID, StringThirdParty) == 2) {
                jButton19.setText("De-Alert");
            } else {
                jButton19.setText("Alert");
            }
            jTextField6.setText(jList1.getSelectedValue().toString());
        }

    }//GEN-LAST:event_jList1MouseClicked

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        final Thread th = new Thread() {
            @Override
            public void run() {
                SQLConnect.refreshAllData();
            }
        };
        jButton8.setVisible(true);
        th.start();
        jButton8.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                th.stop();
                jButton8.setVisible(false);
                return;
            }
        });
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        System.exit(0);
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        jButton9ActionPerformed(evt);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        JOptionPane.showMessageDialog(rootPane, "Property of TeamPirates.\nv1.0 alpha", "About", WIDTH);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        if (jTextField6.getText().isEmpty() || jTextField7.getText().isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "Please enter a valid input.", "Error", WIDTH);
        } else {
            try {
                String coMname = jTextField6.getText();
                int quantity = Integer.parseInt(jTextField7.getText());
                if (quantity < 0) {
                    JOptionPane.showMessageDialog(rootPane, "Enter a positive number.", "No!", WIDTH);
                } else {
                    BigDecimal a = Simulate.simulateSell(coMname, quantity, userID);
                    String name = SQLConnect.getSymbolOfCompanyFromDB(coMname);
                    SQLConnect.updateQuantityOfComapnyAfterSell(name, quantity, userID);
                    jLabel12.setText("Your current buy limit is :"
                            + String.valueOf(SQLConnect.getBudgetFromDB(userID).doubleValue()) + ".");
                    jTabbedPane1.remove(2);
                    UpdatejTable2();

                    SQLConnect.registerTotalChanges(userID, total);
                    drawChart();
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(rootPane, "Please enter a number", "No!", WIDTH);
            }
        }
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        if (jTextField6.getText().isEmpty() || jTextField7.getText().isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "Please enter a valid input.", "Error", WIDTH);
        } else {
            try {
                String coMname = jTextField6.getText();
                int quantity = Integer.parseInt(jTextField7.getText());
                if (quantity < 0) {
                    JOptionPane.showMessageDialog(rootPane, "Enter a positive number.", "No!", WIDTH);
                } else {
                    BigDecimal a = Simulate.simulateBuy(coMname, quantity, userID);
                    String name = SQLConnect.getSymbolOfCompanyFromDB(coMname);
                    if (a.compareTo(SQLConnect.getBudgetFromDB(userID)) == -1) {
                        SQLConnect.updateQuantityOfComapnyAfterBuy(name, quantity, userID);
                        jTabbedPane1.remove(2);
                        UpdatejTable2();

                        SQLConnect.registerTotalChanges(userID, total);
                        drawChart();
                        jLabel12.setText("Your current buy limit is :"
                                + String.valueOf(SQLConnect.getBudgetFromDB(userID).doubleValue()) + ".");
                    } else if (a.compareTo(SQLConnect.getBudgetFromDB(userID)) == 1) {
                        JOptionPane.showMessageDialog(rootPane,
                                "Sorry, You'll exceed your limit if you make this purchase.", "Warning", WIDTH);
                    }
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(rootPane, "Please enter a number", "No!", WIDTH);
            }

        }
    }//GEN-LAST:event_jButton13ActionPerformed

    private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField6ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        SQLConnect.refreshOneCompanyOnlyAtSearch(StringThirdParty);
        UpdatejTable2();
        UpdateRefreshTime();
        jButton10.setVisible(false);
        jButton7.setVisible(false);
        jButton15.setVisible(false);

    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        SQLConnect.refreshPortfolioDataOnly(userID);
        UpdatejTable2();
        UpdateRefreshTime();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
        jList1.clearSelection();
        int row = jTable2.getSelectedRow();
        String name = (jTable2.getModel().getValueAt(row, 0).toString());
        jLabel15.setText("Selected company : '" + name + "'.    " + SQLConnect.checkIfAutomated(userID, name));
        if (jTabbedPane1.getSelectedIndex() == 0) {
            jButton10.setVisible(true);
            jButton7.setVisible(true);
            if (SQLConnect.ifAutomated(userID, name) == 1) {
                jButton15.setText("De-Auto");
            } else if (SQLConnect.ifAutomated(userID, name) == 0) {
                jButton15.setText("Automate");
            }
            if (SQLConnect.ifAutomated(userID, name) == 2) {
                jButton19.setText("De-Alert");
            } else {
                jButton19.setText("Alert");
            }
            jButton15.setVisible(true);
            if (SQLConnect.ifReported(userID, name) == 1) {
                jButton3.setText("Unreport");
            } else {
                jButton3.setText("Report");
            }

            jButton3.setVisible(true);
            jPanel10.setVisible(false);
            StringThirdParty = name;
            jTextField6.setText(name);
        }
        try {
            if (evt.getButton() == MouseEvent.BUTTON3) {

                int decision = JOptionPane.showConfirmDialog(rootPane, "Do you really want to delete " + name + "?",
                        "Remove a company", JOptionPane.YES_NO_OPTION);
                if (decision == JOptionPane.YES_OPTION) {
                    SQLConnect.removeCompanyFromPortfolio(name, userID);
                    UpdatejTable2();
                    SQLConnect.registerTotalChanges(userID, total);
                }

            }
        } catch (Exception e) {
            System.err.println(e);
        }

    }//GEN-LAST:event_jTable2MouseClicked

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        jPanel10.setVisible(true);
        StringBuilder temp = new StringBuilder();
        int row = jTable2.getSelectedRow();
        String name = (jTable2.getModel().getValueAt(row, 0).toString());
        for (YahooNews y : YahooNews.getRss(SQLConnect.getSymbolOfCompanyFromDB(name))) {
            temp.append(y.toString());
        }
        jEditorPane1.setContentType("text/html");
        jEditorPane1.setText(temp.toString());
        jEditorPane1.setCaretPosition(0);
        jEditorPane1.addHyperlinkListener(new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
                    System.out.println(e.getURL());
                    Desktop desktop = Desktop.getDesktop();
                    try {
                        desktop.browse(e.getURL().toURI());
                    } catch (Exception ex) {
                        System.err.println("Problem in link click.\n" + ex);
                    }
                }
            }
        });

        jEditorPane1.setEditable(false);

    }//GEN-LAST:event_jButton7ActionPerformed

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed

        String name = jTextField2.getText();
        String pwd = jPasswordField1.getText().toString();
        if (name.isEmpty() || pwd.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "Please provid a valid input.", "Bad input", WIDTH);
        }

        try {
            boolean a = SQLConnect.createNewUser(name, pwd, 2, new BigDecimal(0));
            if (a == true) {
                JOptionPane.showMessageDialog(rootPane, "Account created successfully.", "Good news", WIDTH);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, "Sorry, Couldn't create account.\n" + e, "Error", WIDTH);
        }

    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        String name = jTextField2.getText();
        String pwd = jPasswordField1.getText().toString();
        if (name.isEmpty() || pwd.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "Please enter a valid input.", "Bad input", WIDTH);
        }
        if (SQLConnect.Login(name, pwd) == true) {
            userID = SQLConnect.getUserID(name);
            switch (SQLConnect.getClearanceFromDB(name)) {
            case 0:
                AdminGui admin = new AdminGui();
                admin.setTitle("News for '" + name + "'");
                admin.setLocationRelativeTo(null);
                admin.setVisible(true);
                this.setVisible(false);
                admin.setDefaultCloseOperation(EXIT_ON_CLOSE);
                break;

            case 1:
                JOptionPane.showMessageDialog(rootPane, "Coming Soon !!", "Patience", WIDTH);
                break;
            case 2:
                loginState = true;
                jPanel7.setVisible(false);
                jPanel9.setVisible(true);
                jLabel11.setText("Welcome " + name);
                jLabel12.setText("Your current buy limit is :"
                        + String.valueOf(SQLConnect.getBudgetFromDB(userID).doubleValue()) + ".");
                checkLoginState(loginState);
                timer = new Timer(1000, new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        jTable2.setEnabled(true);

                        jLabel7.setText("Refreshing in : " + String.valueOf(counter) + "s.");
                        counter--;
                        if (counter == -1) {
                            jTable2.setEnabled(false);
                            jButton5ActionPerformed(e);
                            AutoRunBuyAndSell();
                            counter = 120;
                            actionPerformed(e);
                        }
                    }
                });
                timer.start();

                break;
            default:
                JOptionPane.showMessageDialog(rootPane, "Sorry not found.", "No match", WIDTH);
                break;
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "Sorry no match.\nWe suggest creating a new account",
                    "No match", WIDTH);
        }
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
        jButton11ActionPerformed(evt);
    }//GEN-LAST:event_jPasswordField1ActionPerformed

    private void jTable2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable2KeyReleased
        jList1.clearSelection();
        int row = jTable2.getSelectedRow();
        String name = (jTable2.getModel().getValueAt(row, 0).toString());

        if (evt.getExtendedKeyCode() == KeyEvent.VK_BACK_SPACE || evt.getExtendedKeyCode() == KeyEvent.VK_DELETE) {
            int decision = JOptionPane.showConfirmDialog(rootPane, "Do you really want to delete " + name + "?",
                    "Remove a company", JOptionPane.YES_NO_OPTION);
            if (decision == JOptionPane.YES_OPTION) {
                SQLConnect.removeCompanyFromPortfolio(name, userID);
                UpdatejTable2();
                SQLConnect.registerTotalChanges(userID, total);
            }
        }
    }//GEN-LAST:event_jTable2KeyReleased

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        loginState = false;
        checkLoginState(loginState);
        jTabbedPane1.remove(1);
        jPanel7.setVisible(true);
        jPanel9.setVisible(false);
        jPasswordField1.setText(null);
    }//GEN-LAST:event_jButton17ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        jLabel2.setVisible(true);
        String name = jTextField1.getText();
        SQLConnect.refreshOneCompanyOnlyAtSearch(name);
        if (name.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "Nothing to update.", "Sorry", WIDTH);
        } else {
            Company com = SQLConnect.lookForCompany(name, userID);
            UpdatejTable3(com);
            jLabel2.setText("   Done.");
        }

    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        if (jTextField1.getText().equals("")) {
            JOptionPane.showMessageDialog(rootPane, "Nothing to erase", "Hmmm", WIDTH);
        } else {
            jTextField1.setText(null);
            jButton6.setVisible(false);
            jLabel2.setText(null);
            jLabel2.setVisible(false);
            //jTable3.clearSelection();
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if (loginState == false) {

            String companyName = jTextField1.getText();
            try {
                SQLConnect.refreshOneCompanyOnlyAtSearch(companyName);
                if (companyName.isEmpty()) {
                    JOptionPane.showMessageDialog(rootPane, "Please provide a valid input.", "Bad input", WIDTH);
                } else {
                    Company com = SQLConnect.lookForCompany(companyName, userID);
                    UpdatejTable3(com);
                    jButton6.setVisible(true);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(rootPane, "Sorry, '" + companyName + "' not found !.\n", "Oo-oh",
                        WIDTH);
            }

        } else {
            jScrollPane5.setVisible(true);
            String companyName = jTextField1.getText();
            try {
                SQLConnect.refreshOneCompanyOnlyAtSearch(companyName);
                if (companyName.isEmpty()) {
                    JOptionPane.showMessageDialog(rootPane, "Please provide a valid input.", "Bad input", WIDTH);
                } else {
                    Company com = SQLConnect.lookForCompany(companyName, userID);
                    UpdatejTable3(com);
                    jButton6.setVisible(true);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(rootPane, "Sorry, '" + companyName + "' not found !.\n", "Oo-oh",
                        WIDTH);
            }
        }

    }//GEN-LAST:event_jButton1ActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
        String sub = jTextField3.getText();
        try {
            int test = Integer.parseInt(sub);
            if (sub.isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "Please provide a valid input", "Bad input", WIDTH);
            } else {
                BigDecimal bud = new BigDecimal(sub);
                if (bud.compareTo(BigDecimal.ZERO) < 0) {
                    JOptionPane.showMessageDialog(rootPane, "Enter a positive number !!", "No!", WIDTH);
                } else {
                    SQLConnect.changeLimit(bud, userID);
                }
                jLabel12.setText("Your current buy limit is :"
                        + String.valueOf(SQLConnect.getBudgetFromDB(userID).doubleValue()) + ".");
                jTextField3.setText(null);
            }
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(rootPane, "Please provide a valid number", "Bad input", WIDTH);
        }

    }//GEN-LAST:event_jButton18ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        jButton18ActionPerformed(evt);
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        SQLConnect.markCompanyAsReported(userID, StringThirdParty);
        UpdatejTable2();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
        if (StringThirdParty.equals("")) {
            JOptionPane.showMessageDialog(rootPane, "Please select a company first.", "Oo-Ohh", WIDTH);
        } else if (SQLConnect.ifAutomated(userID, StringThirdParty) == 0) {
            AutomationSettingsGUI auto = new AutomationSettingsGUI(StringThirdParty, userID);
            auto.setLocationRelativeTo(null);
            auto.setTitle("Automation Settings");
            auto.setVisible(true);
            auto.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        } else {
            SQLConnect.removeAutomation(userID, StringThirdParty);
        }
    }//GEN-LAST:event_jButton15ActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed

        if (StringThirdParty.equals("")) {
            JOptionPane.showMessageDialog(rootPane, "Please select a company first.", "Oo-Ohh", WIDTH);
        } else if (SQLConnect.ifAutomated(userID, StringThirdParty) == 2) {
            SQLConnect.removeAutomation(userID, StringThirdParty);
        } else {
            String aux = jTextField4.getText();
            try {
                BigDecimal price = new BigDecimal(jTextField4.getText());
                if (price.compareTo(BigDecimal.ZERO) == 1) {
                    if (jTextField4.getText().isEmpty()) {
                        JOptionPane.showMessageDialog(rootPane, "Please enter a valid input.", "Error", WIDTH);
                    } else {
                        String symb = SQLConnect.getSymbolOfCompanyFromDB(StringThirdParty);

                        SQLConnect.saveAutomateSettings(userID, symb, new BigDecimal(BigInteger.ONE), price, 0, 0,
                                0);

                    }
                } else {
                    JOptionPane.showMessageDialog(rootPane, "Enter a positive number.", "No !", WIDTH);
                }
            } catch (NumberFormatException e) {
                JOptionPane.showMessageDialog(rootPane, "Please provide a valid number", "Bad input", WIDTH);
            }

        }

    }//GEN-LAST:event_jButton19ActionPerformed

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        jButton19ActionPerformed(evt);
    }//GEN-LAST:event_jTextField4ActionPerformed

    private void jTextField7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField7ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField7ActionPerformed

    /**
     * @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 {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Mac OS X".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FirstGUI.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FirstGUI.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FirstGUI.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FirstGUI.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        }
        //</editor-fold>
        //</editor-fold>
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                FirstGUI first = new FirstGUI();
                first.setTitle("Project App - TeamPirates");
                first.setExtendedState(JFrame.MAXIMIZED_BOTH);
                first.setLocationRelativeTo(null);
                first.setVisible(true);

            }
        });
    }

    private void AutoRunBuyAndSell() {
        SQLConnect.performAutomation(userID);
        jTabbedPane1.remove(2);
        UpdatejTable2();
        SQLConnect.registerTotalChanges(userID, total);
        drawChart();
    }

    private void UpdatejTable2() {
        DefaultTableModel modelPortfolio = new DefaultTableModel();
        total = new BigDecimal(0);
        modelPortfolio.setColumnIdentifiers(new String[] { "Name", "Symbol", "Stock Price ()", "Bid Price",
                "Ask Price", "Quantity Bought", "Price Paid" });
        for (Company com : SQLConnect.getPortfolioCompanies(userID)) {
            modelPortfolio
                    .addRow(new String[] { com.getName(), com.getSymbol(),
                            String.valueOf(com.getStockPrice().doubleValue()),
                            String.valueOf(com.getBidPrice().doubleValue()),
                            String.valueOf(com.getAskPrice().doubleValue()), Integer.toString(com.getNumberOwned()),
                            String.valueOf((com.getStockPrice()
                                    .multiply(new BigDecimal(Integer.toString(com.getNumberOwned())))
                                    .doubleValue())) });
            String disturbed = Integer.toString(com.getNumberOwned());
            BigDecimal aa = new BigDecimal(disturbed);
            total = total.add(com.getStockPrice().multiply(aa));
        }
        jLabel10.setText("Total is : " + String.valueOf(total.doubleValue()) + "");
        jTable2.setModel(modelPortfolio);

    }

    private void UpdatejTable3(Company com) {
        DefaultTableModel modelCompany = new DefaultTableModel();
        modelCompany.setColumnIdentifiers(new String[] { "Name", "Symbol", "Stock Price ()", "Bid Price",
                "Ask Price", "Quantity Bought" });
        modelCompany.addRow(new String[] { com.getName(), com.getSymbol(),
                String.valueOf(com.getStockPrice().doubleValue()), String.valueOf(com.getBidPrice().doubleValue()),
                String.valueOf(com.getAskPrice().doubleValue()), Integer.toString(com.getNumberOwned()) });
        jTable3.setModel(modelCompany);
    }

    private void UpdateRefreshTime() {
        try {
            Date date = SQLConnect.getCurrentDate();
            String finaldate = sdf.format(date);
            jLabel5.setText("   " + finaldate);
        } catch (Exception e) {
            System.err.println("Problem in time`\n" + e);
        }
    }

    private void checkLoginState(boolean loginState) {
        if (loginState == false) {
            jTabbedPane1.remove(jPanel5);

        } else {
            jTabbedPane1.add(jPanel5, 0);
            jTabbedPane1.setTitleAt(0, "    My Portfolio    ");
            jTabbedPane1.setSelectedIndex(0);
            UpdatejTable2();
            drawChart();

        }
    }

    private void drawChart() {
        final XYDataset dataset = SQLConnect.getInfoToDrawChart(userID);
        final JFreeChart chart = createChart(dataset);
        final ChartPanel chartPanel = new ChartPanel(chart);
        //chartPanel.setPreferredSize(new java.awt.Dimension(560, 370));
        chartPanel.setMouseZoomable(true, false);
        jTabbedPane1.add("    History    ", chartPanel);
    }

    private JFreeChart createChart(final XYDataset dataset) {
        return ChartFactory.createTimeSeriesChart("History of changes", "Time", "Total", dataset, false, false,
                false);
    }

    Timer timer;
    private int counter = 120;

    private boolean loginState = false;

    private int userID = 0;

    private String StringThirdParty = "";

    private final java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMM dd, yyyy HH:mm:ss");

    private BigDecimal total = new BigDecimal(0);
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JEditorPane jEditorPane1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jList1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    // End of variables declaration//GEN-END:variables
}