Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package userview;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.LinkedList;
- import javax.swing.Timer;
- /**
- *
- * @author kamranali
- */
- public class Userview extends javax.swing.JFrame {
- javax.swing.DefaultComboBoxModel<String> model;
- /**
- * Creates new form userview
- */
- static int rowCount = 0;
- int row_count = 0;//For Row Count
- String for_item_check = "";
- public Userview() {
- ArrayList<String> l = new ArrayList<String>();
- String[] str = (String[]) l.toArray(new String[l.size()]);
- for (String temp : str) {
- System.out.println(temp);
- }
- initComponents();
- new items();
- showDate();
- showTime();
- }
- void showDate() {
- Date d = new Date();
- SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
- date.setText(s.format(d));
- }
- void showTime() {
- new Timer(0, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- Date d = new Date();
- SimpleDateFormat s = new SimpleDateFormat("hh:mm:ss");
- time.setText(s.format(d));
- }
- }).start();
- }
- /**
- * 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() {
- jLabel3 = new javax.swing.JLabel();
- jPanel2 = new javax.swing.JPanel();
- jButton4 = new javax.swing.JButton();
- jLabel5 = new javax.swing.JLabel();
- time = new javax.swing.JLabel();
- date = new javax.swing.JLabel();
- jTabbedPane1 = new javax.swing.JTabbedPane();
- jPanel1 = new javax.swing.JPanel();
- jLabel1 = new javax.swing.JLabel();
- jTextField1 = new javax.swing.JTextField();
- jLabel2 = new javax.swing.JLabel();
- jScrollPane3 = new javax.swing.JScrollPane();
- item_table = new javax.swing.JTable();
- jButton1 = new javax.swing.JButton();
- calculatedPrice = new javax.swing.JTextField();
- itemChoice1 = new java.awt.Choice();
- itemChoice = new java.awt.List();
- jPanel3 = new javax.swing.JPanel();
- addItem = new javax.swing.JButton();
- itemName = new javax.swing.JTextField();
- itemPrice = new javax.swing.JTextField();
- itemAdded = new java.awt.List();
- priceAdded = new java.awt.List();
- jLabel4 = new javax.swing.JLabel();
- jLabel6 = new javax.swing.JLabel();
- jPanel4 = new javax.swing.JPanel();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTable1 = new javax.swing.JTable();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jButton4.setText("logoff");
- jButton4.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton4ActionPerformed(evt);
- }
- });
- jLabel5.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
- jLabel5.setText("Fast Food Restuarant Billing System");
- time.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
- time.setForeground(new java.awt.Color(51, 0, 255));
- time.setText("Time");
- date.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
- date.setForeground(new java.awt.Color(51, 0, 255));
- date.setText("Date");
- javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
- jPanel2.setLayout(jPanel2Layout);
- jPanel2Layout.setHorizontalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addGap(46, 46, 46)
- .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 438, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
- .addComponent(jButton4)
- .addGap(19, 19, 19))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
- .addComponent(time)
- .addGap(33, 33, 33)
- .addComponent(date)
- .addContainerGap())))
- );
- jPanel2Layout.setVerticalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jButton4)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(time)
- .addComponent(date))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- );
- jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
- jLabel1.setText("Customer Name");
- jTextField1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jTextField1ActionPerformed(evt);
- }
- });
- jLabel2.setText("Items");
- item_table.setModel(new javax.swing.table.DefaultTableModel(
- new Object [][] {
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null}
- },
- new String [] {
- "Item", "Quantity", "Price"
- }
- ) {
- Class[] types = new Class [] {
- java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
- };
- public Class getColumnClass(int columnIndex) {
- return types [columnIndex];
- }
- });
- jScrollPane3.setViewportView(item_table);
- jButton1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
- jButton1.setText("Calculate :");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- calculatedPrice.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- calculatedPriceActionPerformed(evt);
- }
- });
- itemChoice1.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- itemChoice1MouseClicked(evt);
- }
- });
- itemChoice.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- itemChoiceMouseClicked(evt);
- }
- });
- itemChoice.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- itemChoiceActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel1)
- .addComponent(jLabel2))
- .addGap(18, 18, 18)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(itemChoice1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addComponent(itemChoice, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(30, Short.MAX_VALUE))
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGap(244, 244, 244)
- .addComponent(jButton1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(calculatedPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(62, 62, 62))
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(itemChoice1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(itemChoice, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
- .addComponent(calculatedPrice))
- .addContainerGap())
- );
- jTabbedPane1.addTab("Bill", jPanel1);
- jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
- addItem.setText("Add Item");
- addItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- addItemActionPerformed(evt);
- }
- });
- itemName.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- itemNameActionPerformed(evt);
- }
- });
- itemAdded.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- itemAddedMouseClicked(evt);
- }
- });
- itemAdded.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- itemAddedActionPerformed(evt);
- }
- });
- priceAdded.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- priceAddedMouseClicked(evt);
- }
- });
- jLabel4.setText("Item");
- jLabel6.setText("Price");
- javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
- jPanel3.setLayout(jPanel3Layout);
- jPanel3Layout.setHorizontalGroup(
- jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addComponent(itemAdded, javax.swing.GroupLayout.PREFERRED_SIZE, 302, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(priceAdded, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 71, Short.MAX_VALUE))
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addGap(179, 179, 179)
- .addComponent(addItem, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(82, 82, 82)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(itemName)
- .addComponent(itemPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addGap(110, 110, 110)
- .addComponent(jLabel4)
- .addGap(246, 246, 246)
- .addComponent(jLabel6)))
- .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(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel6))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(itemAdded, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
- .addComponent(priceAdded, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addComponent(itemName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(itemPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(addItem, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(0, 28, Short.MAX_VALUE))
- );
- jTabbedPane1.addTab("Items", jPanel3);
- jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
- jTable1.setModel(new javax.swing.table.DefaultTableModel(
- new Object [][] {
- {null, null, null},
- {null, null, null},
- {null, null, null},
- {null, null, null}
- },
- new String [] {
- "Date", "Total Items", "Total Price"
- }
- ));
- jScrollPane1.setViewportView(jTable1);
- javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
- jPanel4.setLayout(jPanel4Layout);
- jPanel4Layout.setHorizontalGroup(
- jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 693, Short.MAX_VALUE)
- );
- jPanel4Layout.setVerticalGroup(
- jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
- );
- jTabbedPane1.addTab("Sales", jPanel4);
- 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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jLabel3)
- .addGap(160, 160, 160))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addComponent(jTabbedPane1)
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 348, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel3)
- .addContainerGap())
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
- // TODO add your handling code here:
- this.setVisible(false);
- loginview k = new loginview();
- k.setVisible(true);
- }//GEN-LAST:event_jButton4ActionPerformed
- private void calculatedPriceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calculatedPriceActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_calculatedPriceActionPerformed
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- int total = 0;
- int quantity = 0;
- int price = 0;
- String t ;
- //System.out.println(item_table.getValueAt(0, 2));
- for (int i = 0; i < row_count; i++) {
- //System.out.println(item_table.getValueAt(0, 2));
- // try{
- // quantity = item_table.getValueAt(i, 1);
- quantity=Integer.parseInt(String.valueOf(item_table.getValueAt(i, 1)));
- price=Integer.parseInt(String.valueOf(item_table.getValueAt(i, 2)));
- // price = (int) item_table.getValueAt(i, 2);
- total = total + (quantity * price);
- //t = Integer.toString(total);
- //System.out.println(total);
- //// }catch(ClassCastException e){
- // System.out.println("Exception");
- // }
- }
- // calculatedPrice.setText(String.valueOf(total));
- //calculatedPrice.setText(t);
- //System.out.println(t);
- //calculatedPrice.setText(Integer.toString(total));
- calculatedPrice.setText(Integer.toString(total));
- }//GEN-LAST:event_jButton1ActionPerformed
- private void addItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addItemActionPerformed
- items.price.add(itemPrice.getText());//For Adding Items Price to Static Price List
- items.items.add(itemName.getText());//For Adding Items to Static items List
- itemChoice.addItem(itemName.getText()); //For Adding Item to Combo Box
- itemAdded.addItem(itemName.getText());//For Adding Item to Recently Added Items List
- priceAdded.addItem(itemPrice.getText());//For Adding Item to Recently Added Price Menu
- }//GEN-LAST:event_addItemActionPerformed
- private void itemAddedMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_itemAddedMouseClicked
- // TODO add your handling code here:
- priceAdded.select(itemAdded.getSelectedIndex());
- }//GEN-LAST:event_itemAddedMouseClicked
- private void priceAddedMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_priceAddedMouseClicked
- // TODO add your handling code here:
- itemAdded.select(priceAdded.getSelectedIndex());
- }//GEN-LAST:event_priceAddedMouseClicked
- private void itemChoice1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_itemChoice1MouseClicked
- // TODO add your handling code here:
- // int index = itemChoice1.getSelectedIndex();
- // String itemName = items.items.get(index);
- // String itemPrice = items.price.get(index);
- // item_table.setValueAt(itemName, rowCount, 0);
- // item_table.setValueAt(itemPrice, rowCount, 2);
- // rowCount++;
- }//GEN-LAST:event_itemChoice1MouseClicked
- private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jTextField1ActionPerformed
- private void itemChoiceMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_itemChoiceMouseClicked
- // TODO add your handling code here:
- // int index = itemChoice1.getSelectedIndex();
- // String itemName = items.items.get(index);
- // String itemPrice = items.price.get(index);
- // item_table.setValueAt(itemName, rowCount, 0);
- // item_table.setValueAt(itemPrice, rowCount, 2);
- // rowCount++;
- }//GEN-LAST:event_itemChoiceMouseClicked
- private void itemAddedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemAddedActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_itemAddedActionPerformed
- private void itemChoiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemChoiceActionPerformed
- int index = itemChoice.getSelectedIndex();
- /* String itemName = items.items.get(index);
- String itemPrice = items.price.get(index);
- item_table.setValueAt(itemName, rowCount, 0);
- item_table.setValueAt(itemPrice, rowCount, 2);
- rowCount++;
- row_count++;*/
- String current_item = (String)itemChoice.getSelectedItem();
- item_table.setValueAt(current_item,row_count,0);
- if(row_count==0)
- {
- item_table.setValueAt(current_item, row_count,0);
- }
- else
- {
- item_table.setValueAt(current_item,row_count,0);
- }
- item_table.setValueAt(items.price.get(index), row_count, 2);
- // switch(current_item)
- // {
- // case "Burger":
- // item_table.setValueAt(60,row_count,2);
- // break;
- // case "Shawarma":
- // item_table.setValueAt(90,row_count,2);
- // break;
- // case "Pizza":
- // item_table.setValueAt(1000,row_count,2);
- // break;
- // case "Pratha Roll":
- // item_table.setValueAt(120,row_count,2);
- // break;
- // case "Biryani":
- // item_table.setValueAt(120,row_count,2);
- // break;
- // case "Milk Shake":
- // item_table.setValueAt(60,row_count,2);
- // break;
- // default :
- // break;
- // }
- //item_table.setValueAt(current_item,row_count,0);
- row_count++;
- }//GEN-LAST:event_itemChoiceActionPerformed
- private void itemNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemNameActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_itemNameActionPerformed
- /**
- * @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 ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(userview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(userview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(userview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(userview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Userview().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton addItem;
- private javax.swing.JTextField calculatedPrice;
- private javax.swing.JLabel date;
- public static java.awt.List itemAdded;
- public static java.awt.List itemChoice;
- public static java.awt.Choice itemChoice1;
- private javax.swing.JTextField itemName;
- private javax.swing.JTextField itemPrice;
- public static javax.swing.JTable item_table;
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton4;
- private javax.swing.JLabel jLabel1;
- 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.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JPanel jPanel3;
- private javax.swing.JPanel jPanel4;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JScrollPane jScrollPane3;
- private javax.swing.JTabbedPane jTabbedPane1;
- private javax.swing.JTable jTable1;
- private javax.swing.JTextField jTextField1;
- public static java.awt.List priceAdded;
- private javax.swing.JLabel time;
- // End of variables declaration//GEN-END:variables
- }
- items class
- package userview;
- import java.util.ArrayList;
- import java.util.LinkedList;
- /**
- *
- * @author kamranali
- */
- public class items {
- static ArrayList<String> items = new ArrayList<String>();
- static ArrayList<String> price = new ArrayList<String>();
- // int rowCount = 7;
- static int index = 0;
- public items()
- {
- items.add("Burger");
- price.add("60");
- Userview.itemChoice.addItem("Burger");
- Userview.itemAdded.add("Burger");
- Userview.priceAdded.add("60");
- items.add("Shawarma");
- price.add("90");
- Userview.itemChoice.addItem("Shawarma");
- Userview.itemAdded.add("Shawarma");
- Userview.priceAdded.add("90");
- items.add("Pizza");
- price.add("1000");
- Userview.itemChoice.addItem("Pizza");
- Userview.itemAdded.add("Pizza");
- Userview.priceAdded.add("1000");
- items.add("Pratha Roll");
- price.add("120");
- Userview.itemChoice.addItem("Pratha Roll");
- Userview.itemAdded.add("Pratha Roll");
- Userview.priceAdded.add("120");
- items.add("Biryani");
- price.add("120");
- Userview.itemChoice.addItem("Biryani");
- Userview.itemAdded.add("Biryani");
- Userview.priceAdded.add("120");
- items.add("Milk Shake");
- price.add("60");
- Userview.itemChoice.addItem("Milk Shake");
- Userview.itemAdded.add("Milk Shake");
- Userview.priceAdded.add("60");
- Userview.itemChoice.addItem(items.get(index));
- index++;
- }}
- /*
- * 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 userview;
- /**
- *
- * @author kamranali
- */
- import java.awt.event.KeyEvent;
- import javax.swing.JOptionPane;
- public class loginview extends javax.swing.JFrame {
- /**
- * Creates new form loginview
- */
- public loginview() {
- initComponents();
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jPanel1 = new javax.swing.JPanel();
- jLabel2 = new javax.swing.JLabel();
- login_btn = new javax.swing.JButton();
- pass = new javax.swing.JPasswordField();
- jLabel1 = new javax.swing.JLabel();
- user = new javax.swing.JTextField();
- jLabel3 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Login", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 24), new java.awt.Color(0, 0, 255))); // NOI18N
- jLabel2.setText("Password");
- login_btn.setText("Login");
- login_btn.setMnemonic(KeyEvent.VK_ENTER);
- login_btn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- login_btnActionPerformed(evt);
- }
- });
- jLabel1.setText("Username");
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(user, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addComponent(jLabel2)
- .addGap(45, 45, 45)
- .addComponent(pass, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap())
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addComponent(login_btn)
- .addGap(57, 57, 57))))
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(user, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel1))
- .addGap(31, 31, 31)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel2))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
- .addComponent(login_btn))
- );
- jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/project1/windows-10-user-account-login-icon.png"))); // NOI18N
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGap(39, 39, 39)
- .addComponent(jLabel3)
- .addGap(38, 38, 38)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(50, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(35, 35, 35)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addGap(59, 59, 59)
- .addComponent(jLabel3)))
- .addContainerGap(53, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void login_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_login_btnActionPerformed
- // TODO add your handling code here:
- singleton auth = new singleton();
- if(auth.adminAuth.get(0).equalsIgnoreCase(user.getText())){
- if(auth.adminAuth.get(1).equalsIgnoreCase(pass.getText())){
- Userview view = new Userview();
- view.setVisible(true);
- this.setVisible(false);
- }else{
- JOptionPane.showMessageDialog(null," Inavalid Password ");
- }
- }else{
- JOptionPane.showMessageDialog(null," Invalid User ");
- }
- }//GEN-LAST:event_login_btnActionPerformed
- /**
- * @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 ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(loginview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(loginview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(loginview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(loginview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new loginview().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JButton login_btn;
- private javax.swing.JPasswordField pass;
- private javax.swing.JTextField user;
- // End of variables declaration//GEN-END:variables
- }
- //singleton class
- package userview;
- /**
- *
- * @author kamranali
- */
- import java.util.ArrayList;
- public class singleton {
- ArrayList<String> adminAuth = new ArrayList<String>();
- singleton(){
- adminAuth.add("admin");
- adminAuth.add("admin");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement