public void setCheckin(Checkin checkin) { this.checkin = checkin; if (checkin == null) { this.jLabelCode.setText("<html>Kodi: <b>?"); this.jLabelDate.setText("<html>Data: <b>?"); this.jLabelTime.setText("<html>Ora: <b>?"); this.jLabel1.setText("<html>Furnitori<b>?"); this.jLabelTotValue.setText("<html>Tot.: <>?"); this.items = new ArrayList(); } else { this.jLabelCode.setText("<html>Kodi: <b>" + checkin.getCode()); this.jLabelDate.setText( "<html>Data: <b>" + checkin.getEmissionTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy"))); this.jLabelTime.setText( "<html>Ora: <b>" + checkin.getEmissionTime().format(DateTimeFormatter.ofPattern("HH.mm.ss"))); this.jLabel1.setText("<html>Furnitori: <b>" + checkin.getSupplier()); this.jLabelTotValue.setText("<html>Tot.: " + checkin.getValue()); this.items = checkin.getItems(); } DecimalFormat df = new DecimalFormat(); df.applyPattern("#,##0.0#"); String[] header = {"Kodi", "Emertimi", "Marka", "Tipi", "Sasia", "Cmimi", "Vlera"}; Object[][] data = new Object[this.items.size()][header.length]; for (int r = 0; r < this.items.size(); r++) { data[r][0] = this.items.get(r).getCode(); data[r][1] = this.items.get(r).getName(); data[r][2] = this.items.get(r).getBrand(); data[r][3] = this.items.get(r).getType(); data[r][4] = this.items.get(r).getQuantity(); data[r][5] = this.items.get(r).getValue(); data[r][6] = this.items.get(r).getValue() * this.items.get(r).getQuantity(); } DefaultTableModel dtm = new DefaultTableModel(data, header) { @Override public boolean isCellEditable(int r, int c) { return false; } @Override public Class getColumnClass(int columnIndex) { Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Float.class, java.lang.Float.class }; return types[columnIndex]; } }; this.jTableItems.setModel(dtm); }
private void jButtonPrint2ActionPerformed( java.awt.event.ActionEvent evt) // GEN-FIRST:event_jButtonPrint2ActionPerformed { // GEN-HEADEREND:event_jButtonPrint2ActionPerformed if (checkin == null) return; checkin.saveToHTML("./temp/checkin/checkin.html"); try { Runtime rTime = Runtime.getRuntime(); String url = System.getProperty("user.dir") + "/temp/checkin/checkin.html"; String browser = "C:/Program Files/Internet Explorer/iexplore.exe "; rTime.exec(browser + url); } catch (IOException ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } } // GEN-LAST:event_jButtonPrint2ActionPerformed