Java tutorial
/* * 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 userInterface.CustomerWorkArea; import Business.CarInspection.CarInspection; import Business.Enterprise.InsuranceEnterprise; import Business.Organization.CustomerOrganization; import Business.UserAccount.UserAccount; import Business.WorkQueue.WorkRequest; import java.awt.CardLayout; import java.awt.Color; import java.util.ArrayList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.table.DefaultTableModel; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.DefaultCategoryDataset; /** * * @author amuly */ public class ViewSensorHistoryJPanel extends javax.swing.JPanel { /** * Creates new form ViewSensorHistoryJPanel */ private JPanel userProcessContainer; private CustomerOrganization organization; private InsuranceEnterprise enterprise; private UserAccount userAccount; public ViewSensorHistoryJPanel(JPanel userProcessContainer, CustomerOrganization customerOrganization, InsuranceEnterprise insuranceEnterprise, UserAccount account) { initComponents(); this.userProcessContainer = userProcessContainer; this.organization = customerOrganization; this.enterprise = insuranceEnterprise; this.userAccount = account; populateTable(); } public void populateTable() { DefaultTableModel model = (DefaultTableModel) sensorJTable.getModel(); model.setRowCount(0); for (CarInspection carInspection : userAccount.getPerson().getCarInspectionHistory() .getCarInspectionHistory()) { Object[] row = new Object[7]; row[0] = carInspection.getTimestamp(); row[1] = carInspection.getAlignment(); row[2] = carInspection.getBattery(); row[3] = carInspection.getBrakingSys(); row[4] = carInspection.getOilCheck(); row[5] = carInspection.getPollutionLevel(); row[6] = carInspection.getTyrePressure(); model.addRow(row); } } /** * 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(); jScrollPane1 = new javax.swing.JScrollPane(); sensorJTable = new javax.swing.JTable(); bckJBtn = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); setLayout(new java.awt.BorderLayout()); jPanel1.setBackground(new java.awt.Color(153, 153, 255)); sensorJTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { }, new String[] { "TimeStamp", "Alignment", "Battery", "Braking System", "Oil Check", "Pollution", "Tyre Pressure" })); jScrollPane1.setViewportView(sensorJTable); bckJBtn.setText("Back"); bckJBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bckJBtnActionPerformed(evt); } }); jLabel1.setFont(new java.awt.Font("Tempus Sans ITC", 0, 24)); // NOI18N jLabel1.setText("View Sensor History"); 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(732, 732, 732).addComponent(jLabel1)) .addGroup(jPanel1Layout.createSequentialGroup().addGap(339, 339, 339).addGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bckJBtn).addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1019, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(501, Short.MAX_VALUE))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(84, 84, 84).addComponent(jLabel1) .addGap(90, 90, 90) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(81, 81, 81).addComponent(bckJBtn).addContainerGap(261, Short.MAX_VALUE))); add(jPanel1, java.awt.BorderLayout.CENTER); }// </editor-fold>//GEN-END:initComponents private void bckJBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bckJBtnActionPerformed userProcessContainer.remove(this); CardLayout layout = (CardLayout) userProcessContainer.getLayout(); layout.previous(userProcessContainer); // TODO add your handling code here: }//GEN-LAST:event_bckJBtnActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton bckJBtn; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable sensorJTable; // End of variables declaration//GEN-END:variables }