Stock Control program in java
This program is for controlling the stock. User can perform several
actions like- checking stock , adding stock, verification of password,
purchasing item, and updating stock.
/*
* 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 stockcontrolsimulation;
/**
*
* @author walid
*/
public class Master extends javax.swing.JFrame {
/**
* Creates new form Master
*/
public Master() {
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();
lblTitle = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
btncheckStock = new javax.swing.JButton();
btnPurchaseItem = new javax.swing.JButton();
btnUpdateStock = new javax.swing.JButton();
btnExit = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
lblTitle.setFont(new java.awt.Font("Tahoma", 1, 12)); //
NOI18N
lblTitle.setText("Select an option by clicking one of the
buttons below");
lblTitle.setPreferredSize(new java.awt.Dimension(332, 20));
jPanel1.add(lblTitle);
getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
btncheckStock.setText("Check stock");
btncheckStock.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent
evt) {
btncheckStockActionPerformed(evt);
}
});
jPanel2.add(btncheckStock);
btnPurchaseItem.setText("Purchase item");
btnPurchaseItem.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent
evt) {
btnPurchaseItemActionPerformed(evt);
}
});
jPanel2.add(btnPurchaseItem);
btnUpdateStock.setText("Update stock");
btnUpdateStock.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent
evt) {
btnUpdateStockActionPerformed(evt);
}
});
jPanel2.add(btnUpdateStock);
btnExit.setText("Exit");
btnExit.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent
evt) {
btnExitActionPerformed(evt);
}
});
jPanel2.add(btnExit);
getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnExitActionPerformed(java.awt.event.ActionEvent
evt) {//GEN-FIRST:event_btnExitActionPerformed
//When exit button clicked, close the application
System.exit(0);
}//GEN-LAST:event_btnExitActionPerformed
private void
btncheckStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_btncheckStockActionPerformed
//when button check Stock clicked display the checkStock
JFrame
(new CheckStock()).setVisible(true);
}//GEN-LAST:event_btncheckStockActionPerformed
private void
btnPurchaseItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_btnPurchaseItemActionPerformed
// Display PurchaseItem JFrame
new PurchaseItem().setVisible(true);
}//GEN-LAST:event_btnPurchaseItemActionPerformed
private void
btnUpdateStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_btnUpdateStockActionPerformed
// // Display PasswordVerif JFrame
new PasswordVerif().setVisible(true);
}//GEN-LAST:event_btnUpdateStockActionPerformed
//The Main function
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Java look and feel */
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels())
{
if ("Java".equals(info.getName()))
{
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Master.class.getName()).log(java.ut
il.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Master.class.getName()).log(java.ut
il.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Master.class.getName()).log(java.ut
il.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Master.class.getName()).log(java.ut
il.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Master().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnExit;
private javax.swing.JButton btnPurchaseItem;
private javax.swing.JButton btnUpdateStock;
private javax.swing.JButton btncheckStock;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JLabel lblTitle;
// End of variables declaration//GEN-END:variables
}
Contacts