import java.util.ArrayList;
public class PaydayGUI extends javax.swing.JFrame {
ArrayList<Payday> myList = new ArrayList<>();
/**
* Creates new form PaydayGUI
*/
public PaydayGUI() {
initComponents();
tfEmpID.setText("");
tfHoursWorked.setText("");
tfSalary.setText("");
}
/**
* 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">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
cleardisplayPanel = new javax.swing.JPanel();
btnDisplayHourly = new javax.swing.JButton();
btnDisplayPartTime = new javax.swing.JButton();
btnDisplayAll = new javax.swing.JButton();
btnClrAllTxtBoxes = new javax.swing.JButton();
btnDltAllEmp = new javax.swing.JButton();
cbEmployeeList = new javax.swing.JComboBox();
hourlyPartTimePanel = new javax.swing.JPanel();
hoursWorkedLbl = new javax.swing.JLabel();
tfHoursWorked = new javax.swing.JTextField();
salariedPanel = new javax.swing.JPanel();
salaryLbl = new javax.swing.JLabel();
tfSalary = new javax.swing.JTextField();
empIDPanel = new javax.swing.JPanel();
txtEmployeeID = new javax.swing.JLabel();
tfEmpID = new javax.swing.JTextField();
lblEmployeeTracker = new javax.swing.JLabel();
btnAddHourly = new javax.swing.JButton();
btnAddPartTime = new javax.swing.JButton();
btnAddSalaried = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
cleardisplayPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Clear and Display"));
btnDisplayHourly.setText("Display Hourly");
btnDisplayHourly.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDisplayHourlyActionPerformed(evt);
}
});
btnDisplayPartTime.setText("Display Part Time");
btnDisplayAll.setText("Display All");
btnClrAllTxtBoxes.setText("Clear All Text Boxes");
btnClrAllTxtBoxes.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnClrAllTxtBoxesActionPerformed(evt);
}
});
btnDltAllEmp.setText("Delete all Employees");
cbEmployeeList.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbEmployeeList.addContainerListener(new java.awt.event.ContainerAdapter() {
public void componentAdded(java.awt.event.ContainerEvent evt) {
cbEmployeeListComponentAdded(evt);
}
});
javax.swing.GroupLayout cleardisplayPanelLayout = new javax.swing.GroupLayout(cleardisplayPanel);
cleardisplayPanel.setLayout(cleardisplayPanelLayout);
cleardisplayPanelLayout.setHorizontalGroup(
cleardisplayPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(cleardisplayPanelLayout.createSequentialGroup()
.addGap(38, 38, 38)
.addGroup(cleardisplayPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnDisplayHourly, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnDisplayPartTime, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnDisplayAll, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(cleardisplayPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(btnClrAllTxtBoxes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnDltAllEmp, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
.addComponent(cbEmployeeList, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(66, 66, 66))
);
cleardisplayPanelLayout.setVerticalGroup(
cleardisplayPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(cleardisplayPanelLayout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(cleardisplayPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnDisplayHourly)
.addComponent(cbEmployeeList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(cleardisplayPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnDisplayPartTime)
.addComponent(btnClrAllTxtBoxes))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(cleardisplayPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnDisplayAll)
.addComponent(btnDltAllEmp))
.addContainerGap(23, Short.MAX_VALUE))
);
hourlyPartTimePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Hourly and Part Time"));
hoursWorkedLbl.setText("Hours Worked");
tfHoursWorked.setText("jTextField2");
javax.swing.GroupLayout hourlyPartTimePanelLayout = new javax.swing.GroupLayout(hourlyPartTimePanel);
hourlyPartTimePanel.setLayout(hourlyPartTimePanelLayout);
hourlyPartTimePanelLayout.setHorizontalGroup(
hourlyPartTimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(hourlyPartTimePanelLayout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(hoursWorkedLbl)
.addGap(47, 47, 47)
.addComponent(tfHoursWorked, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(59, Short.MAX_VALUE))
);
hourlyPartTimePanelLayout.setVerticalGroup(
hourlyPartTimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(hourlyPartTimePanelLayout.createSequentialGroup()
.addGap(39, 39, 39)
.addGroup(hourlyPartTimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(hoursWorkedLbl)
.addComponent(tfHoursWorked, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(45, Short.MAX_VALUE))
);
salariedPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Salared"));
salaryLbl.setText("Salary");
tfSalary.setText("jTextField3");
javax.swing.GroupLayout salariedPanelLayout = new javax.swing.GroupLayout(salariedPanel);
salariedPanel.setLayout(salariedPanelLayout);
salariedPanelLayout.setHorizontalGroup(
salariedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(salariedPanelLayout.createSequentialGroup()
.addGap(36, 36, 36)
.addComponent(salaryLbl)
.addGap(60, 60, 60)
.addComponent(tfSalary, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(53, Short.MAX_VALUE))
);
salariedPanelLayout.setVerticalGroup(
salariedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(salariedPanelLayout.createSequentialGroup()
.addGap(39, 39, 39)
.addGroup(salariedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(salaryLbl)
.addComponent(tfSalary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(44, Short.MAX_VALUE))
);
empIDPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
txtEmployeeID.setText("Employee ID");
tfEmpID.setText("jTextField1");
tfEmpID.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tfEmpIDActionPerformed(evt);
}
});
javax.swing.GroupLayout empIDPanelLayout = new javax.swing.GroupLayout(empIDPanel);
empIDPanel.setLayout(empIDPanelLayout);
empIDPanelLayout.setHorizontalGroup(
empIDPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(empIDPanelLayout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(txtEmployeeID, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)
.addComponent(tfEmpID, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(20, Short.MAX_VALUE))
);
empIDPanelLayout.setVerticalGroup(
empIDPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(empIDPanelLayout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(empIDPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtEmployeeID, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tfEmpID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(21, Short.MAX_VALUE))
);
lblEmployeeTracker.setFont(new java.awt.Font("Lucida Calligraphy", 1, 14)); // NOI18N
lblEmployeeTracker.setText("Employee Tracker");
btnAddHourly.setText("Add Hourly");
btnAddHourly.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddHourlyActionPerformed(evt);
}
});
btnAddPartTime.setText("Add Part Time");
btnAddPartTime.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddPartTimeActionPerformed(evt);
}
});
btnAddSalaried.setText("Add Salaried");
btnAddSalaried.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddSalariedActionPerformed(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()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(cleardisplayPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(hourlyPartTimePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(salariedPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(170, 170, 170)
.addComponent(empIDPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(215, 215, 215)
.addComponent(lblEmployeeTracker)))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(52, 52, 52)
.addComponent(btnAddHourly)
.addGap(18, 18, 18)
.addComponent(btnAddPartTime)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnAddSalaried)
.addGap(110, 110, 110))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(32, Short.MAX_VALUE)
.addComponent(lblEmployeeTracker)
.addGap(40, 40, 40)
.addComponent(empIDPanel, 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.LEADING)
.addComponent(salariedPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(hourlyPartTimePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnAddHourly)
.addComponent(btnAddPartTime)
.addComponent(btnAddSalaried))
.addGap(33, 33, 33)
.addComponent(cleardisplayPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void tfEmpIDActionPerformed(java.awt.event.ActionEvent evt) {
}
private void btnAddHourlyActionPerformed(java.awt.event.ActionEvent evt) {
double hoursWorked = Double.parseDouble(tfHoursWorked.getText());
String empID = tfEmpID.getText();
HourlyEmployee hrEmp = new HourlyEmployee(empID, hoursWorked);
myList.add(hrEmp);
}
private void btnAddPartTimeActionPerformed(java.awt.event.ActionEvent evt) {
double hoursWorked = Double.parseDouble(tfHoursWorked.getText());
String empID = tfEmpID.getText();
PartTimeEmployee ptEmp = new PartTimeEmployee(empID, hoursWorked);
myList.add(ptEmp);
}
private void btnAddSalariedActionPerformed(java.awt.event.ActionEvent evt) {
double salary = Double.parseDouble(tfSalary.getText());
String empID = tfEmpID.getText();
SalariedEmployee salEmp = new SalariedEmployee(empID, salary);
myList.add(salEmp);
}
private void btnClrAllTxtBoxesActionPerformed(java.awt.event.ActionEvent evt) {
tfEmpID.setText("");
tfHoursWorked.setText("");
tfSalary.setText("");
}
private void btnDisplayHourlyActionPerformed(java.awt.event.ActionEvent evt) {
cbEmployeeList.removeAllItems();
}
private void cbEmployeeListComponentAdded(java.awt.event.ContainerEvent evt) {
// TODO add your handling code here:
}
/**
* @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(PaydayGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(PaydayGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(PaydayGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(PaydayGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new PaydayGUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnAddHourly;
private javax.swing.JButton btnAddPartTime;
private javax.swing.JButton btnAddSalaried;
private javax.swing.JButton btnClrAllTxtBoxes;
private javax.swing.JButton btnDisplayAll;
private javax.swing.JButton btnDisplayHourly;
private javax.swing.JButton btnDisplayPartTime;
private javax.swing.JButton btnDltAllEmp;
private javax.swing.JComboBox cbEmployeeList;
private javax.swing.JPanel cleardisplayPanel;
private javax.swing.JPanel empIDPanel;
private javax.swing.JPanel hourlyPartTimePanel;
private javax.swing.JLabel hoursWorkedLbl;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblEmployeeTracker;
private javax.swing.JPanel salariedPanel;
private javax.swing.JLabel salaryLbl;
private javax.swing.JTextField tfEmpID;
private javax.swing.JTextField tfHoursWorked;
private javax.swing.JTextField tfSalary;
private javax.swing.JLabel txtEmployeeID;
// End of variables declaration
}