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 Statement; import DBConnection.DBConnection; import com.toedter.calendar.DateUtil; import com.toedter.calendar.IDateEvaluator; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import static java.sql.Types.INTEGER; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Vector; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.table.DefaultTableModel; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.DefaultCategoryDataset; /** * * @author nguyenkimminhhang */ public class Statement extends javax.swing.JPanel { Connection cnn; Vector shopID; Vector<Vector> fieldData; Vector fieldNames; DefaultTableModel model; int fix, other, rev, profit, cost; String date; String code = ""; HighlightEvaluator evaluator; /** * Creates new form Statement */ public Statement() { initComponents(); cnn = DBConnection.getDBConnection(); loadShopID(); loadRevenue(); loadExpense(); } private static class HighlightEvaluator implements IDateEvaluator { private static List<Date> list = new ArrayList<>(); private DateUtil dateUtil = new DateUtil(); public void add(Date date) { list.add(date); } @Override public boolean isSpecial(Date date) { return list.contains(date); } @Override public Color getSpecialForegroundColor() { return Color.red.darker(); } @Override public Color getSpecialBackroundColor() { return Color.blue; } @Override public String getSpecialTooltip() { return "Statement event."; } @Override public boolean isInvalid(Date date) { return dateUtil.checkDate(date); } @Override public Color getInvalidForegroundColor() { return null; } @Override public Color getInvalidBackroundColor() { return null; } @Override public String getInvalidTooltip() { return null; } /** * Sets the initial date in the range to be validated. * @param startDate */ public void setStartDate(Date startDate) { dateUtil.setMinSelectableDate(startDate); } /** * @return the initial date in the range to be validated. */ public Date getStartDate() { return dateUtil.getMinSelectableDate(); } /** * Sets the final date in the range to be validated. * @param endDate */ public void setEndDate(Date endDate) { dateUtil.setMaxSelectableDate(endDate); } /** * @return the final date in the range to be validated. */ public Date getEndDate() { return dateUtil.getMaxSelectableDate(); } } private void loadExpense() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_YEAR, 1); Date tomorrow = calendar.getTime(); dateFormat.format(tomorrow); evaluator = new HighlightEvaluator(); evaluator.setStartDate(tomorrow); try { PreparedStatement st = cnn.prepareStatement("SELECT Date FROM Expense where ShopID = ?"); st.setString(1, code); ResultSet rs = st.executeQuery(); while (rs.next()) { evaluator.add(rs.getDate(1)); } } catch (Exception e) { } jc.getDayChooser().addDateEvaluator(evaluator); jc.setCalendar(jc.getCalendar()); } private void loadRevenue() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_YEAR, 1); Date tomorrow = calendar.getTime(); dateFormat.format(tomorrow); evaluator = new HighlightEvaluator(); evaluator.setStartDate(tomorrow); try { PreparedStatement st = cnn.prepareStatement("SELECT Date FROM Revenue where ShopID = ?"); st.setString(1, code); ResultSet rs = st.executeQuery(); while (rs.next()) { evaluator.add(rs.getDate(1)); } } catch (Exception e) { } jc.getDayChooser().addDateEvaluator(evaluator); jc.setCalendar(jc.getCalendar()); } private void loadShopID() { shopID = new Vector(); try { PreparedStatement st = cnn.prepareStatement("select ShopID from Shop"); ResultSet rs = st.executeQuery(); while (rs.next()) { shopID.add(rs.getString(1)); } cbShopID.setModel(new DefaultComboBoxModel(shopID)); } catch (Exception e) { } } private void load() { //Display dong Fix va Other Cost try { PreparedStatement st = cnn .prepareStatement("select Fixed,Other from Expense where ShopID = ? and Date = ?"); st.setString(1, code); st.setString(2, date); ResultSet rs = st.executeQuery(); while (rs.next()) { txtFix.setText(customFormat("VND ###,###,###", rs.getInt(1))); fix = rs.getInt(1); txtOther.setText(customFormat("VND ###,###,###", rs.getInt(2))); other = rs.getInt(2); } } catch (SQLException e) { System.err.println(e.getMessage()); } //Display dong Revenue String query = "{call Revenue_Shop_Date(?,?,?)}"; try { CallableStatement cst = cnn.prepareCall(query); cst.setString(1, code); cst.setString(2, date); cst.registerOutParameter(3, INTEGER); cst.execute(); txtRev.setText(customFormat("VND ###,###,###", cst.getInt(3))); rev = cst.getInt(3); } catch (Exception e) { } //Display dong Profit cost = fix + other; profit = rev - cost; txtProfit.setText(customFormat("VND ###,###,###", profit)); //Display comment try { PreparedStatement st1 = cnn.prepareStatement("select Goal from Shop where ShopID = ?"); st1.setString(1, code); ResultSet rs1 = st1.executeQuery(); while (rs1.next()) { int goal = rs1.getInt(1); if (rev >= goal) { comment.setText("Congrats! The Shop has achieved the goal"); } else { comment.setText("The Shop has failed the goal"); } } } catch (SQLException e) { System.err.println(e.getMessage()); } } private void loadView() { fieldData = new Vector<>(); fieldNames = new Vector(); //Display Revenue try { PreparedStatement st = cnn .prepareStatement("SELECT TypeName,Quantity FROM Revenue where ShopID = ? and Date = ?"); st.setString(1, code); st.setString(2, date); ResultSet rs = st.executeQuery(); ResultSetMetaData meta = rs.getMetaData(); for (int i = 1; i <= meta.getColumnCount(); i++) { fieldNames.add(meta.getColumnName(i)); } while (rs.next()) { Vector tmp = new Vector(); tmp.add(rs.getString(1)); tmp.add(rs.getInt(2)); fieldData.add(tmp); } model = new DefaultTableModel(fieldData, fieldNames); tbl.setModel(model); } catch (Exception e) { } } //dinh dang so public String customFormat(String pattern, double value) { DecimalFormat myFormatter = new DecimalFormat(pattern); String output = myFormatter.format(value); return output; } private void barchart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(rev, "Values", "Revenue"); dataset.setValue(cost, "Values", "Cost"); dataset.setValue(profit, "Values", "Profit"); JFreeChart chart = ChartFactory.createBarChart3D("Statement", "", "VND", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.blue); ChartPanel chartpanel = new ChartPanel(chart); pnChart.setPreferredSize(new Dimension(340, 275)); pnChart.removeAll(); pnChart.add(chartpanel, BorderLayout.CENTER); pnChart.validate(); } /** * 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(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); txtRev = new javax.swing.JLabel(); txtFix = new javax.swing.JLabel(); txtOther = new javax.swing.JLabel(); txtProfit = new javax.swing.JLabel(); pnComment = new javax.swing.JPanel(); comment = new javax.swing.JLabel(); btnExport = new javax.swing.JButton(); cbShopID = new javax.swing.JComboBox<>(); txtDate = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); tbl = new javax.swing.JTable(); jc = new com.toedter.calendar.JCalendar(); pnChart = new javax.swing.JPanel(); setBackground(new java.awt.Color(255, 255, 153)); jPanel1.setBackground(new java.awt.Color(255, 255, 0)); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Statement", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(255, 0, 0))); // NOI18N jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel1.setText("Date:"); jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel2.setText("Shop ID:"); jPanel2.setBackground(new java.awt.Color(255, 255, 153)); jLabel3.setText("Revenue:"); jLabel4.setText("Fixed Cost:"); jLabel5.setText("Other Cost:"); jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel6.setForeground(new java.awt.Color(255, 0, 0)); jLabel6.setText("Profit:"); txtRev.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N txtRev.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); txtFix.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N txtFix.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); txtOther.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N txtOther.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); txtProfit.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N txtProfit.setForeground(new java.awt.Color(255, 0, 0)); txtProfit.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); 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(40, 40, 40) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel6).addComponent(jLabel5).addComponent(jLabel4) .addComponent(jLabel3)) .addGap(18, 18, 18) .addGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txtRev, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(txtFix, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(txtOther, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(txtProfit, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3).addComponent(txtRev)) .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4).addComponent(txtFix)) .addGap(20, 20, 20) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5).addComponent(txtOther)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6).addComponent(txtProfit)) .addContainerGap())); pnComment.setBackground(new java.awt.Color(255, 255, 153)); pnComment.setBorder( javax.swing.BorderFactory.createTitledBorder(null, "Comment", javax.swing.border.TitledBorder.RIGHT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N pnComment.setForeground(new java.awt.Color(255, 0, 0)); comment.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N comment.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); javax.swing.GroupLayout pnCommentLayout = new javax.swing.GroupLayout(pnComment); pnComment.setLayout(pnCommentLayout); pnCommentLayout .setHorizontalGroup(pnCommentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnCommentLayout.createSequentialGroup().addGap(20, 20, 20) .addComponent(comment, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); pnCommentLayout .setVerticalGroup(pnCommentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnCommentLayout.createSequentialGroup().addGap(26, 26, 26) .addComponent(comment, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(38, Short.MAX_VALUE))); btnExport.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N btnExport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Load.png"))); // NOI18N btnExport.setText("Export"); btnExport.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnExportActionPerformed(evt); } }); cbShopID.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cbShopIDItemStateChanged(evt); } }); txtDate.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N txtDate.setHorizontalAlignment(javax.swing.JTextField.CENTER); txtDate.setEnabled(false); 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().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(44, 44, 44) .addComponent(jLabel1)) .addGroup( jPanel1Layout.createSequentialGroup().addGap(36, 36, 36) .addComponent(jLabel2))) .addGap(18, 18, 18) .addGroup(jPanel1Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(cbShopID, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(txtDate, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(btnExport)))) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(pnComment, javax.swing.GroupLayout.PREFERRED_SIZE, 340, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(47, 47, 47) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbShopID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(btnExport) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(18, 18, 18) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(pnComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); jPanel3.setBackground(new java.awt.Color(255, 255, 51)); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "VIEW REVENUE", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(255, 0, 0))); // NOI18N tbl.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { }, new String[] { "Type Name", "Quantity" }) { Class[] types = new Class[] { java.lang.String.class, java.lang.Integer.class }; boolean[] canEdit = new boolean[] { false, false }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); jScrollPane2.setViewportView(tbl); 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() .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup().addContainerGap().addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE))); jc.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { jcPropertyChange(evt); } }); pnChart.setBackground(new java.awt.Color(255, 255, 51)); pnChart.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "BarChart", javax.swing.border.TitledBorder.RIGHT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N pnChart.setLayout(new java.awt.BorderLayout()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jc, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE) .addComponent(pnChart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(0, 0, 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() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jc, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(pnChart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap())); }// </editor-fold>//GEN-END:initComponents private void btnExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportActionPerformed load(); loadView(); barchart(); }//GEN-LAST:event_btnExportActionPerformed private void jcPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jcPropertyChange SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); date = sdf.format(jc.getDate()); txtDate.setText(date); }//GEN-LAST:event_jcPropertyChange private void cbShopIDItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbShopIDItemStateChanged cbShopID = (JComboBox) evt.getSource(); code = "" + evt.getItem(); if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) { loadRevenue(); loadExpense(); } else if (evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) { evaluator.list.clear(); } }//GEN-LAST:event_cbShopIDItemStateChanged // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnExport; private javax.swing.JComboBox<String> cbShopID; private javax.swing.JLabel comment; 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.JScrollPane jScrollPane2; private com.toedter.calendar.JCalendar jc; private javax.swing.JPanel pnChart; private javax.swing.JPanel pnComment; private javax.swing.JTable tbl; private javax.swing.JTextField txtDate; private javax.swing.JLabel txtFix; private javax.swing.JLabel txtOther; private javax.swing.JLabel txtProfit; private javax.swing.JLabel txtRev; // End of variables declaration//GEN-END:variables }