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 net.linra; import java.awt.Dimension; import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListModel; import javax.swing.JLabel; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.DefaultCategoryDataset; public class AttendanceSystemFrame extends javax.swing.JFrame { private int absentNumber_int; /** * Creates new form AttendanceSystemFrame */ public AttendanceSystemFrame() { initComponents(); DefaultListModel model = (DefaultListModel) jList1.getModel(); String[] strings = { "student1", "student2", "student3", "student4", "student5", "student6", "student7", "student8", "student9", "student10", "student11", "student12", "student13", "student14", "student15", "student16", "student17", "student18", "student19", "student20", "student21", "student22", "student23", "student24", "student25" }; for (String item : strings) { model.addElement(item); } } /** * 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() { jPanel3 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel(); student1 = new javax.swing.JLabel(); student2 = new javax.swing.JLabel(); student3 = new javax.swing.JLabel(); student4 = new javax.swing.JLabel(); student10 = new javax.swing.JLabel(); student9 = new javax.swing.JLabel(); student8 = new javax.swing.JLabel(); student7 = new javax.swing.JLabel(); student6 = new javax.swing.JLabel(); student11 = new javax.swing.JLabel(); student12 = new javax.swing.JLabel(); student13 = new javax.swing.JLabel(); student14 = new javax.swing.JLabel(); student15 = new javax.swing.JLabel(); student20 = new javax.swing.JLabel(); student19 = new javax.swing.JLabel(); student18 = new javax.swing.JLabel(); student17 = new javax.swing.JLabel(); student16 = new javax.swing.JLabel(); student21 = new javax.swing.JLabel(); student22 = new javax.swing.JLabel(); student23 = new javax.swing.JLabel(); student24 = new javax.swing.JLabel(); student25 = new javax.swing.JLabel(); student5 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); absentNumber = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList<>(); jPanel4 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jPanel8 = new javax.swing.JPanel(); studentCombobox = new javax.swing.JComboBox<>(); jButton2 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTree1 = new javax.swing.JTree(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenuItem2 = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Smart Attendence Systen"); setBackground(new java.awt.Color(102, 102, 102)); jPanel3.setBackground(new java.awt.Color(255, 255, 255)); jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jPanel1.setBorder( javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Student", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N student1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student1.setText("student1"); student2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student2.setText("student2"); student3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student3.setText("student3"); student4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student4.setText("student4"); student10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student10.setText("student10"); student9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student9.setText("student9"); student8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student8.setText("student8"); student7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student7.setText("student7"); student6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student6.setText("student6"); student11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student11.setText("student11"); student12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student12.setText("student12"); student13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student13.setText("student13"); student14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student14.setText("student14"); student15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student15.setText("student15"); student20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student20.setText("student20"); student19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student19.setText("student19"); student18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student18.setText("student18"); student17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student17.setText("student17"); student16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student16.setText("student16"); student21.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student21.setText("student21"); student22.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student22.setText("student22"); student23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student23.setText("student23"); student24.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student24.setText("student24"); student25.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student25.setText("student25"); student5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N student5.setText("student5"); 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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(student1).addComponent(student2).addComponent(student3) .addComponent(student4).addComponent(student5)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(34, 34, 34) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(student7).addComponent(student6) .addComponent(student8).addComponent(student9)) .addGap(26, 26, 26)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(student10).addGap(18, 18, 18))) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(student12).addComponent(student11).addComponent(student13) .addComponent(student14).addComponent(student15)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(student17).addComponent(student16).addComponent(student18) .addComponent(student19).addComponent(student20)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(student22).addComponent(student23).addComponent(student21) .addComponent(student24).addComponent(student25)) .addGap(229, 229, 229))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(student1) .addGap(12, 12, 12).addComponent(student2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(student3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(student4)) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(student11) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(student12).addGap(78, 78, 78) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(student14).addComponent(student19) .addComponent(student24))) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(student21) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(student22))) .addGap(12, 12, 12) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(student15).addComponent(student10).addComponent(student5))) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(student6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(student7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(student8).addComponent(student13).addComponent(student18) .addComponent(student23)) .addGap(18, 18, 18).addComponent(student9)) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(student16) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(student17).addGap(138, 138, 138) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(student20).addComponent(student25)))) .addContainerGap(11, Short.MAX_VALUE))); jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/student.png"))); // NOI18N jLabel1.setText("Absent student:"); absentNumber.setText("25"); jLabel3.setText("Student who are absent:"); jList1.setModel(new javax.swing.DefaultListModel()); jScrollPane2.setViewportView(jList1); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(absentNumber)) .addComponent(jLabel3)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addGap(16, 16, 16) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1).addComponent(absentNumber)) .addGap(12, 12, 12).addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2).addContainerGap())); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE)); jButton1.setBackground(new java.awt.Color(204, 204, 204)); jButton1.setText("Check In"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel8.setBackground(new java.awt.Color(255, 255, 255)); studentCombobox.setModel(new javax.swing.DefaultComboBoxModel<>( new String[] { "student1", "student2", "student3", "student4", "student5", "student6", "student7", "student8", "student9", "student10", "student11", "student12", "student13", "student14", "student15", "student16", "student17", "student18", "student19", "student20", "student21", "student22", "student23", "student24", "student25" })); studentCombobox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { studentComboboxActionPerformed(evt); } }); javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); jPanel8.setLayout(jPanel8Layout); jPanel8Layout .setHorizontalGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup() .addComponent(studentCombobox, 0, 199, Short.MAX_VALUE).addContainerGap())); jPanel8Layout.setVerticalGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup() .addComponent(studentCombobox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))); jButton2.setText("Graph"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root"); javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Month1"); javax.swing.tree.DefaultMutableTreeNode treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("1"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("2"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("3"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("4"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("5"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("6"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("7"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("8"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("9"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("10"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("11"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("12"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("13"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("14"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("15"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("16"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("17"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("18"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("19"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("20"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("21"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("22"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("23"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("24"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("25"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("26"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("27"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("28"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("29"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("30"); treeNode2.add(treeNode3); treeNode1.add(treeNode2); treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Month2"); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("1"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("2"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("3"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("4"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("5"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("6"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("7"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("8"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("9"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("10"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("11"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("12"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("13"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("14"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("15"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("16"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("17"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("18"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("19"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("20"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("21"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("22"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("23"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("24"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("25"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("26"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("27"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("28"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("29"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("30"); treeNode2.add(treeNode3); treeNode1.add(treeNode2); treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Month3"); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("1"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("2"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("3"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("4"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("5"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("6"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("7"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("8"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("9"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("10"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("11"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("12"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("13"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("14"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("15"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("16"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("17"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("18"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("19"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("20"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("21"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("22"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("23"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("24"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("25"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("26"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("27"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("28"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("29"); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("30"); treeNode2.add(treeNode3); treeNode1.add(treeNode2); jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); jScrollPane1.setViewportView(jTree1); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 689, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 591, Short.MAX_VALUE))))); jMenu1.setText("File"); jMenuItem1.setText("open"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu1.add(jMenuItem1); jMenuBar1.add(jMenu1); jMenu2.setText("Check in"); jMenuItem2.setText("Simulator"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu2.add(jMenuItem2); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 12, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 37, Short.MAX_VALUE))); pack(); }// </editor-fold>//GEN-END:initComponents private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jMenuItem1ActionPerformed private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jMenuItem2ActionPerformed private void studentComboboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_studentComboboxActionPerformed }//GEN-LAST:event_studentComboboxActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed JLabel[] labels = { student1, student2, student3, student4, student5, student6, student7, student8, student9, student10, student11, student12, student13, student14, student15, student16, student17, student18, student19, student20, student21, student22, student23, student24, student25 }; if (jList1.getModel().getSize() <= 0) { this.jButton1.setEnabled(false); } else { int i = studentCombobox.getSelectedIndex(); String name = studentCombobox.getSelectedItem().toString(); for (JLabel label : labels) { if (name.equals(label.getText())) { label.setIcon( new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/present.png"))); } } this.absentNumber.setText((jList1.getModel().getSize() - 1) + ""); DefaultListModel model = (DefaultListModel) jList1.getModel(); model.removeElementAt(i); DefaultComboBoxModel model2 = (DefaultComboBoxModel) studentCombobox.getModel(); model2.removeElementAt(i); jPanel4.removeAll(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(4, "", "Last Month"); dataset.setValue(7, "", "Last Week"); dataset.setValue(3, "", "Yesterday"); dataset.setValue(Integer.parseInt(this.absentNumber.getText()), "", "Today"); JFreeChart chart = ChartFactory.createBarChart("Histgram of absent student", "Data", "Absent number", dataset, PlotOrientation.VERTICAL, true, true, false); ChartPanel p = new ChartPanel(chart); p.setSize(jPanel4.getWidth(), jPanel4.getHeight()); p.setVisible(true); jPanel4.add(p); jPanel4.repaint(); } }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: jPanel4.removeAll(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(4, "", "Last Month"); dataset.setValue(7, "", "Last Week"); dataset.setValue(3, "", "Yesterday"); dataset.setValue(Integer.parseInt(this.absentNumber.getText()), "", "Today"); JFreeChart chart = ChartFactory.createBarChart("Histgram of absent student", "Data", "Absent number", dataset, PlotOrientation.VERTICAL, true, true, false); ChartPanel p = new ChartPanel(chart); p.setSize(jPanel4.getWidth(), jPanel4.getHeight()); p.setVisible(true); jPanel4.add(p); jPanel4.repaint(); //ChartFrame frame = new ChartFrame("Chart1", chart); //frame.setVisible(true); System.out.println(Integer.parseInt(this.absentNumber.getText()) + ""); }//GEN-LAST:event_jButton2ActionPerformed /** * @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. b * 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(AttendanceSystemFrame.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(AttendanceSystemFrame.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(AttendanceSystemFrame.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(AttendanceSystemFrame.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 AttendanceSystemFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel absentNumber; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel3; private javax.swing.JList<String> jList1; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel8; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTree jTree1; private javax.swing.JLabel student1; private javax.swing.JLabel student10; private javax.swing.JLabel student11; private javax.swing.JLabel student12; private javax.swing.JLabel student13; private javax.swing.JLabel student14; private javax.swing.JLabel student15; private javax.swing.JLabel student16; private javax.swing.JLabel student17; private javax.swing.JLabel student18; private javax.swing.JLabel student19; private javax.swing.JLabel student2; private javax.swing.JLabel student20; private javax.swing.JLabel student21; private javax.swing.JLabel student22; private javax.swing.JLabel student23; private javax.swing.JLabel student24; private javax.swing.JLabel student25; private javax.swing.JLabel student3; private javax.swing.JLabel student4; private javax.swing.JLabel student5; private javax.swing.JLabel student6; private javax.swing.JLabel student7; private javax.swing.JLabel student8; private javax.swing.JLabel student9; private javax.swing.JComboBox<String> studentCombobox; // End of variables declaration//GEN-END:variables }