Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: bilal baig
Added: Jan 7, 2018 1:45 PM
Views: 11
Tags: no tags
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package dom;
  7.  
  8. import java.awt.Color;
  9. import java.awt.Desktop;
  10. import java.util.logging.Level;
  11. import javax.swing.UIManager;
  12. import javax.swing.UnsupportedLookAndFeelException;
  13. import java.awt.Insets;
  14. import java.awt.Point;
  15. import java.awt.image.BufferedImage;
  16. import java.io.File;
  17. import java.io.FileInputStream;
  18. import java.io.IOException;
  19. import java.sql.SQLException;
  20. import java.util.ArrayList;
  21. import java.util.concurrent.TimeUnit;
  22. import javax.swing.BorderFactory;
  23. import javax.swing.ImageIcon;
  24. import javax.swing.SwingWorker;
  25. import javax.swing.UIManager;
  26. import javax.swing.UnsupportedLookAndFeelException;
  27. import javax.swing.table.DefaultTableModel;
  28. import java.util.logging.Level;
  29. import java.util.logging.Logger;
  30. import javax.imageio.ImageIO;
  31. import javax.swing.Icon;
  32. import javax.swing.JButton;
  33. import javax.swing.JLabel;
  34.  
  35. /**
  36.  *
  37.  * @author Bilal
  38.  */
  39. public class Menu extends javax.swing.JFrame {
  40.  
  41.     //private String userDefaultImagePath=new File("").getAbsolutePath()+"\\test\\user.png";
  42.     /**
  43.      * Creates new form Menu
  44.      */
  45.     int i = 0;
  46.     int r=212;
  47.     int g=230;
  48.     int b=241;
  49.     DataBaseManager dbm = new DataBaseManager();
  50.  
  51.     public Menu() throws IOException, SQLException {
  52.         initComponents();
  53.         jPanel1.setBackground(new Color(212, 230, 241));
  54.         jPanel2.setBackground(new Color(0, 78, 164));
  55.         txtLeder.setBackground(new Color(0, 78, 164));
  56.         ArrayList<String> arrayStr = new ArrayList<>();
  57.         arrayStr = dbm.getFromLedger();
  58.         for (int j = 0; j < arrayStr.size(); j++) {
  59.  
  60.             txtLeder.append(arrayStr.get(j).toString() + "\n\n");
  61.         }
  62.     }
  63.  
  64.     /**
  65.      * This method is called from within the constructor to initialize the form.
  66.      * WARNING: Do NOT modify this code. The content of this method is always
  67.      * regenerated by the Form Editor.
  68.      */
  69.     @SuppressWarnings("unchecked")
  70.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  71.     private void initComponents() {
  72.  
  73.         jPanel1 = new javax.swing.JPanel();
  74.         jPanel2 = new javax.swing.JPanel();
  75.         jScrollPane1 = new javax.swing.JScrollPane();
  76.         txtLeder = new javax.swing.JTextArea();
  77.         jLabel2 = new javax.swing.JLabel();
  78.         btnClose = new javax.swing.JButton();
  79.         lblName = new javax.swing.JLabel();
  80.         lblPassword = new javax.swing.JLabel();
  81.         btnLogin = new javax.swing.JButton();
  82.         txtPassword = new javax.swing.JPasswordField();
  83.         btnRegister = new javax.swing.JButton();
  84.         jToggleButton1 = new javax.swing.JToggleButton();
  85.         lblUser = new javax.swing.JLabel();
  86.         txtName = new javax.swing.JTextField();
  87.  
  88.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  89.  
  90.         jPanel2.setForeground(new java.awt.Color(0, 0, 255));
  91.  
  92.         txtLeder.setEditable(false);
  93.         txtLeder.setColumns(20);
  94.         txtLeder.setRows(5);
  95.         jScrollPane1.setViewportView(txtLeder);
  96.  
  97.         jLabel2.setIcon(new javax.swing.ImageIcon("C:\\Users\\Bilal\\Desktop\\splash_2.png")); // NOI18N
  98.  
  99.         javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
  100.         jPanel2.setLayout(jPanel2Layout);
  101.         jPanel2Layout.setHorizontalGroup(
  102.             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  103.             .addGroup(jPanel2Layout.createSequentialGroup()
  104.                 .addContainerGap()
  105.                 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  106.                     .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 445, Short.MAX_VALUE)
  107.                     .addGroup(jPanel2Layout.createSequentialGroup()
  108.                         .addComponent(jLabel2)
  109.                         .addGap(0, 0, Short.MAX_VALUE)))
  110.                 .addContainerGap())
  111.         );
  112.         jPanel2Layout.setVerticalGroup(
  113.             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  114.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
  115.                 .addContainerGap()
  116.                 .addComponent(jLabel2)
  117.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  118.                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
  119.                 .addContainerGap())
  120.         );
  121.  
  122.         btnClose.setText("Close");
  123.         btnClose.addActionListener(new java.awt.event.ActionListener() {
  124.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  125.                 btnCloseActionPerformed(evt);
  126.             }
  127.         });
  128.  
  129.         lblName.setText("User name");
  130.  
  131.         lblPassword.setText("Password");
  132.  
  133.         btnLogin.setText("Login");
  134.  
  135.         btnRegister.setText("Register");
  136.         btnRegister.addActionListener(new java.awt.event.ActionListener() {
  137.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  138.                 btnRegisterActionPerformed(evt);
  139.             }
  140.         });
  141.  
  142.         jToggleButton1.setText("theme");
  143.         jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
  144.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  145.                 jToggleButton1ActionPerformed(evt);
  146.             }
  147.         });
  148.  
  149.         lblUser.setIcon(new javax.swing.ImageIcon("C:\\Users\\Bilal\\Desktop\\user_2.png")); // NOI18N
  150.  
  151.         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  152.         jPanel1.setLayout(jPanel1Layout);
  153.         jPanel1Layout.setHorizontalGroup(
  154.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  155.             .addGroup(jPanel1Layout.createSequentialGroup()
  156.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  157.                     .addComponent(jToggleButton1)
  158.                     .addGroup(jPanel1Layout.createSequentialGroup()
  159.                         .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  160.                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  161.                             .addGroup(jPanel1Layout.createSequentialGroup()
  162.                                 .addGap(61, 61, 61)
  163.                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  164.                                     .addComponent(lblPassword)
  165.                                     .addComponent(lblName))
  166.                                 .addGap(36, 36, 36)
  167.                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  168.                                     .addGroup(jPanel1Layout.createSequentialGroup()
  169.                                         .addComponent(btnRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
  170.                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
  171.                                         .addComponent(btnLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
  172.                                     .addComponent(txtPassword, javax.swing.GroupLayout.Alignment.LEADING)
  173.                                     .addComponent(txtName, javax.swing.GroupLayout.Alignment.LEADING)))
  174.                             .addGroup(jPanel1Layout.createSequentialGroup()
  175.                                 .addGap(338, 338, 338)
  176.                                 .addComponent(btnClose, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
  177.                             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
  178.                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  179.                                 .addComponent(lblUser)
  180.                                 .addGap(139, 139, 139)))))
  181.                 .addContainerGap(20, Short.MAX_VALUE))
  182.         );
  183.         jPanel1Layout.setVerticalGroup(
  184.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  185.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
  186.                 .addGap(14, 14, 14)
  187.                 .addComponent(jToggleButton1)
  188.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  189.                 .addComponent(lblUser)
  190.                 .addGap(16, 16, 16)
  191.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  192.                     .addComponent(lblName)
  193.                     .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  194.                 .addGap(18, 18, 18)
  195.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  196.                     .addComponent(lblPassword)
  197.                     .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  198.                 .addGap(18, 18, 18)
  199.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  200.                     .addComponent(btnLogin)
  201.                     .addComponent(btnRegister))
  202.                 .addGap(120, 120, 120)
  203.                 .addComponent(btnClose)
  204.                 .addGap(27, 27, 27))
  205.             .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  206.         );
  207.  
  208.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  209.         getContentPane().setLayout(layout);
  210.         layout.setHorizontalGroup(
  211.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  212.             .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  213.         );
  214.         layout.setVerticalGroup(
  215.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  216.             .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  217.         );
  218.  
  219.         pack();
  220.     }// </editor-fold>                        
  221.  
  222.     private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {                                        
  223.         // TODO add your handling code here:
  224.         dispose();
  225.     }                                        
  226.  
  227.     private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                              
  228.         // TODO add your handling code here:
  229.         if (i == 0) {
  230.             r=202;
  231.             g=207;
  232.             b=210;
  233.             jPanel1.setBackground(new Color(202, 207, 210));
  234.             jPanel2.setBackground(new Color(98, 101, 103));
  235.             txtLeder.setBackground(new Color(98, 101, 103));
  236.             i++;
  237.         } else {
  238.             r=212;
  239.             g=230;
  240.             b=241;
  241.             jPanel1.setBackground(new Color(212, 230, 241));
  242.             jPanel2.setBackground(new Color(0, 78, 164));
  243.             txtLeder.setBackground(new Color(0, 78, 164));
  244.             i = 0;
  245.         }
  246.     }                                              
  247.  
  248.     private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {                                            
  249.         // TODO add your handling code here:
  250.         Register reg=new Register(r,g,b);
  251.        
  252.         reg.setVisible(true);
  253.        
  254.  
  255. //        lblName.setVisible(false);
  256. //        lblPassword.setVisible(false);
  257. //        lblUser.setVisible(false);
  258. //        txtName.setVisible(false);
  259. //        txtPassword.setVisible(false);
  260. //        btnLogin.setVisible(false);
  261. //        btnRegister.setVisible(false);
  262.     }                                          
  263.  
  264.     /**
  265.      * @param args the command line arguments
  266.      */
  267.     public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
  268.         /* Set the Nimbus look and feel */
  269.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  270.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  271.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  272.          */
  273.         try {
  274.             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  275.         } catch (UnsupportedLookAndFeelException ex) {
  276.             Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
  277.         }
  278.         //</editor-fold>
  279.  
  280.         /* Create and display the form */
  281.         java.awt.EventQueue.invokeLater(new Runnable() {
  282.             public void run() {
  283.                 try {
  284.                     new Menu().setVisible(true);
  285.                 } catch (IOException ex) {
  286.                     Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
  287.                 } catch (SQLException ex) {
  288.                     Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
  289.                 }
  290.             }
  291.         });
  292.  
  293.     }
  294.  
  295.     // Variables declaration - do not modify                    
  296.     private javax.swing.JButton btnClose;
  297.     private javax.swing.JButton btnLogin;
  298.     private javax.swing.JButton btnRegister;
  299.     private javax.swing.JLabel jLabel2;
  300.     private javax.swing.JPanel jPanel1;
  301.     private javax.swing.JPanel jPanel2;
  302.     private javax.swing.JScrollPane jScrollPane1;
  303.     private javax.swing.JToggleButton jToggleButton1;
  304.     private javax.swing.JLabel lblName;
  305.     private javax.swing.JLabel lblPassword;
  306.     private javax.swing.JLabel lblUser;
  307.     private javax.swing.JTextArea txtLeder;
  308.     private javax.swing.JTextField txtName;
  309.     private javax.swing.JPasswordField txtPassword;
  310.     // End of variables declaration                  
  311.  
  312. }
  313.