List of usage examples for javax.swing.table DefaultTableModel getRowCount
public int getRowCount()
From source file:proyecto4.Principal.java
private void btn_agregar_prod_a_lista_esperaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_agregar_prod_a_lista_esperaMouseClicked // TODO add your handling code here: try {/*from w w w . j av a2 s . c o m*/ System.out.println(lista_ingredientes.toString()); String nom = txt_nom_prod.getText(); int time = Integer.parseInt(txt_tiempo_prep.getText()); double precio = Double.parseDouble(txt_prec_prod.getText()); DefaultTableModel modelo = (DefaultTableModel) jt_agre_ingre.getModel(); ArrayList temp = new ArrayList(); for (int i = 0; i < modelo.getRowCount(); i++) { temp.add((jt_agre_ingre.getValueAt(i, 1).toString())); } lista_ordenes_espera.add(new Producto_O_Orden(nom, precio, time, temp)); JOptionPane.showMessageDialog(this, "Producto ah sido agregado"); for (int i = 0; i < lista_ordenes_espera.size(); i++) { for (int j = 0; j < lista_ingredientes.size(); j++) { if (lista_ordenes_espera.get(i).getLista().toString() .contains(lista_ingredientes.get(j).getNombre())) { lista_ingredientes.remove(lista_ingredientes.get(j)); } } } DefaultTableModel modelo1 = (DefaultTableModel) jt_agre_ingre.getModel(); for (int i = 0; i < modelo1.getRowCount(); i++) { modelo1.removeRow(i); } System.out.println(lista_ingredientes.toString()); txt_nom_prod.setText(""); txt_prec_prod.setText(""); txt_tiempo_prep.setText(""); } catch (Exception e) { JOptionPane.showMessageDialog(this, "No ah sido agregado"); } }
From source file:proyecto4.Principal.java
private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed // TODO add your handling code here: DefaultTableModel modelo1 = (DefaultTableModel) jt_ordenes_camiones.getModel(); for (int i = 0; i < modelo1.getRowCount(); i++) { modelo1.removeRow(i);//w ww . ja v a 2s . c om } for (int i = 0; i < lista_ordenes_cocineros.size(); i++) { modelo1.addRow(new Object[] { false, lista_ordenes_cocineros.get(i).getNombre().toString() }); } jd_camiones.setModal(true); jd_camiones.pack(); jd_camiones.setVisible(true); }
From source file:proyecto4.Principal.java
private void btn_aceptar_ordenes_camionesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_aceptar_ordenes_camionesMouseClicked // TODO add your handling code here: String camion = (String) cb_camiones.getSelectedItem(); ArrayList temp = new ArrayList(9); DefaultTableModel modelo = (DefaultTableModel) jt_ordenes_camiones.getModel(); for (int i = 0; i < modelo.getRowCount(); i++) { for (int j = 0; j < temp.size(); j++) { if (temp.size() <= 9) { System.out.println(j); if (jt_ordenes_camiones.getValueAt(i, 0).equals(true)) { System.out.println("valida si el coso es true y agrega"); temp.add((jt_ordenes_camiones.getValueAt(i, 1).toString())); }//from ww w . j a v a2 s . c o m } else { JOptionPane.showMessageDialog(this, "Camion full, elija otro"); } } } lista_camiones.add(new Camion(camion, temp)); System.out.println(lista_camiones.toString()); temp = new ArrayList(9); }
From source file:Records.Database.LibraryUpdater.java
/** * Delete file./* w ww. j ava 2s. c o m*/ */ private static void deleteFile() { System.out.println("LibraryUpdater.deleteFile()"); DefaultTableModel model = (DefaultTableModel) RecordsMain.getUI().getUserLibrary().getModel(); String ID = null; for (int x = 0; x < paths.size(); x++) { try (ResultSet Result = RecordsMain.dba.getIDByPath(paths.get(x).toString())) { if (Result.next()) { ID = Result.getString("Song_ID"); ResultSet results = RecordsMain.dba.SearchLibByID(ID); try { // While there are more results to process if (results.next()) { String title = results.getString("SONG_TITLE"); String artist = results.getString("ARTIST"); String album = results.getString("ALBUM"); String genre = results.getString("GENRE"); for (int y = 0; y < model.getRowCount(); y++) { if (model.getValueAt(y, 0).equals(title) && model.getValueAt(y, 1).equals(artist) && model.getValueAt(y, 2).equals(album) && model.getValueAt(y, 3).equals(genre)) { // System.out.println("Removing Row!"); model.removeRow(y); RecordsMain.dba.deleteByID("LibSongs", ID); RecordsMain.dba.deleteByID("LibAlbums", ID); RecordsMain.dba.deleteByID("LibArtists", ID); RecordsMain.dba.deleteByID("LibFilePaths", ID); } } RecordsMain.getUI().NumSongs.setText("" + model.getRowCount() + " Songs"); } results.close(); } catch (SQLException ex) { Logger.getLogger(LibraryUpdater.class.getName()).log(Level.SEVERE, null, ex); } RecordsMain.clearFilePathList(); ResultSet res = RecordsMain.dba.getAllFilePaths(); try { while (res.next()) { String fPath = res.getString("Filepath"); RecordsMain.addToFilePathList(fPath); } } catch (SQLException ex) { Logger.getLogger(DBSQL.class.getName()).log(Level.SEVERE, null, ex); } } } catch (SQLException ex) { Logger.getLogger(LibraryUpdater.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:Records.Database.LibraryUpdater.java
@Override public void run() { System.out.println("LibraryUpdater.run()"); DefaultTableModel model = (DefaultTableModel) RecordsMain.getUI().getUserLibrary().getModel(); if (model.getRowCount() != 0) { ResultSet res = null;/*from w w w . ja va2 s.co m*/ try { res = RecordsMain.dba.getLibDirectory(); } catch (SQLException ex) { Logger.getLogger(LibraryUpdater.class.getName()).log(Level.SEVERE, null, ex); } String Dir = null; try { if (!(res.next())) { // System.err.println("No Directory!"); } else { Dir = res.getString("Directory"); // System.out.println(Dir); } res.close(); } catch (SQLException ex) { Logger.getLogger(LibraryUpdater.class.getName()).log(Level.SEVERE, null, ex); } while (running) { System.out.println("Updating"); try { paths = new ArrayList(RecordsMain.getFilePathList()); System.out.println("Counting Files"); countDirectoryFiles(new File(Dir)); if (!paths.isEmpty()) { deleteFile(); } System.out.println("Sleeping..."); Thread.sleep(10000); } catch (InterruptedException e) { Logger.getLogger(SplashClass.class.getName()).log(Level.SEVERE, null, e); running = false; } } } }
From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.simulation.SimulationTopComponent.java
private void loadRules(DefaultTableModel model, List<Data> dataList) { //delete all old simulation rules while (model.getRowCount() != 0) { model.removeRow(0);//from w ww .java 2s. co m } //add new simulation rules for (Data rule : dataList) { model.addRow(new Object[] { rule.getId(), rule.getName(), rule.getSourceVertex().getName(), rule.getDestinationVertex().getName(), rule.isPing() }); } }
From source file:sms.ViewResults.java
public void findUsers() { methods nn = new methods(); Form1Exams n = new Form1Exams(); String[] Subjects = n.findSubjectid(); String[] Subjectsnames = n.findSubjectname(); int subjectCount = Subjects.length; //JOptionPane.showMessageDialog(null, subjectCount); ArrayList<ExamDbDataHolder> users = ListUsers(this.sid.getText()); DefaultTableModel model = new DefaultTableModel(); // String [] subjectsIdentifiers={"Maths","Eng","Kisw","Phy","Chem","Bio","Hist","Geo","Cre","Hre","Agri","Home Scie","Arts","Comp", // "B/c","Wood","Metal","Music","French","German","Arabic","Business"}; // for(int y=0;y<Subjects.length;y++){ // /*from w ww. java 2 s . c o m*/ // } // String []toCol; String col[] = { "Adm", "Uniq", "Total", "Ave", "AGG" }; // String [] subjectsIdentifiers={} String[] both = (String[]) ArrayUtils.addAll(col, Subjectsnames); model.setColumnIdentifiers(both); Object[] row = new Object[subjectCount + 6]; for (int i = 0; i < users.size(); i++) { row[0] = ((ExamDbDataHolder) users.get(i)).getSid(); row[1] = ((ExamDbDataHolder) users.get(i)).getUnique(); row[2] = ((ExamDbDataHolder) users.get(i)).getTotal(); float g = Float.valueOf(((ExamDbDataHolder) users.get(i)).getTotal()); // tbl.addCell(String.format("%.1f", g)); row[3] = String.format("%.1f", g / getYear()); String gr = nn.checkGrade(yearid, String.format("%.1f", g / getYear())); row[4] = gr; int c = 5; for (int s = 0; s < Subjects.length; s++) { if (Subjects[s].equals("s1")) { row[c] = ((ExamDbDataHolder) users.get(i)).getMathematics(); c++; } else if (Subjects[s].equals("s2")) { row[c] = ((ExamDbDataHolder) users.get(i)).getEnglish(); c++; } else if (Subjects[s].equals("s3")) { row[c] = ((ExamDbDataHolder) users.get(i)).getKiswahili(); c++; } else if (Subjects[s].equals("s4")) { row[c] = ((ExamDbDataHolder) users.get(i)).getPhysics(); c++; } else if (Subjects[s].equals("s5")) { row[c] = ((ExamDbDataHolder) users.get(i)).getChemistry(); c++; } else if (Subjects[s].equals("s6")) { row[c] = ((ExamDbDataHolder) users.get(i)).getBiology(); c++; } else if (Subjects[s].equals("s7")) { row[c] = ((ExamDbDataHolder) users.get(i)).getHistory(); c++; } else if (Subjects[s].equals("s8")) { row[c] = ((ExamDbDataHolder) users.get(i)).getGeography(); c++; } else if (Subjects[s].equals("s9")) { row[c] = ((ExamDbDataHolder) users.get(i)).getCre(); c++; } else if (Subjects[s].equals("s10")) { row[c] = ((ExamDbDataHolder) users.get(i)).getIre(); c++; } else if (Subjects[s].equals("s11")) { row[c] = ((ExamDbDataHolder) users.get(i)).getHre(); c++; } else if (Subjects[s].equals("s12")) { row[c] = ((ExamDbDataHolder) users.get(i)).getAgriculture(); c++; } else if (Subjects[s].equals("s13")) { row[c] = ((ExamDbDataHolder) users.get(i)).getHomescience(); c++; } else if (Subjects[s].equals("s14")) { row[c] = ((ExamDbDataHolder) users.get(i)).getArtdesign(); c++; } else if (Subjects[s].equals("s15")) { row[c] = ((ExamDbDataHolder) users.get(i)).getComputer(); c++; } else if (Subjects[s].equals("s16")) { row[c] = ((ExamDbDataHolder) users.get(i)).getBuilding(); c++; } else if (Subjects[s].equals("s17")) { row[c] = ((ExamDbDataHolder) users.get(i)).getWoodwork(); c++; } else if (Subjects[s].equals("s18")) { row[c] = ((ExamDbDataHolder) users.get(i)).getMetalwork(); c++; } else if (Subjects[s].equals("s19")) { row[c] = ((ExamDbDataHolder) users.get(i)).getMusic(); c++; } else if (Subjects[s].equals("s20")) { row[c] = ((ExamDbDataHolder) users.get(i)).getFrench(); c++; } else if (Subjects[s].equals("s21")) { row[c] = ((ExamDbDataHolder) users.get(i)).getGerman(); c++; } else if (Subjects[s].equals("s22")) { row[c] = ((ExamDbDataHolder) users.get(i)).getArabic(); c++; } else if (Subjects[s].equals("s23")) { row[c] = ((ExamDbDataHolder) users.get(i)).getBusiness(); c++; } } model.addRow(row); } this.table.setModel(model); counter(model.getRowCount()); }
From source file:View.Sending.java
private void clearTable() { DefaultTableModel dm = (DefaultTableModel) user_table.getModel(); int rowCount = dm.getRowCount(); for (int i = rowCount - 1; i >= 0; i--) { dm.removeRow(i);// www . ja v a 2 s.co m } }
From source file:View.Sending.java
private void send_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_send_buttonActionPerformed // TODO add your handling code here: DefaultTableModel dtm = (DefaultTableModel) user_table.getModel(); int nRow = dtm.getRowCount(), nCol = dtm.getColumnCount(); Boolean count = false;/*from w ww .ja va 2s .co m*/ for (int i = 0; i < nRow; i++) { boolean isSelected = (boolean) dtm.getValueAt(i, 4); if (isSelected) { count = true; new sendFileThread().start(); send_button.setEnabled(false); } } if (count == false) { JOptionPane.showMessageDialog(rootPane, "Select user"); } }
From source file:View.Sending.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // TODO add your handling code here: DefaultTableModel dtm = (DefaultTableModel) user_table.getModel(); Dbcon dbcon = new Dbcon(); int nRow = dtm.getRowCount(), nCol = dtm.getColumnCount(); for (int i = 0; i < nRow; i++) { boolean isSelected = (boolean) dtm.getValueAt(i, 4); if (isSelected) { System.out.println(dtm.getValueAt(i, 1) + " is selected"); int userId = Integer.parseInt(dtm.getValueAt(i, 5).toString()); ResultSet rs = dbcon.select("select * from tbl_user_details where user_id='" + userId + "'"); try { if (rs.next()) { String receiver_id = rs.getString("email_id"); System.out.println(receiver_id); MailSenderThread mailSenderThread = new MailSenderThread(receiver_id); mailSenderThread.start(); int ins = dbcon.insert( "insert into tbl_transactions(sender_id, received_id,file,send, transaction_date,history_id) values (" + Login.logged_in_user_id + " ,' " + userId + "' ,'" + outputCipherFile.getName() + "',1, '" + System.currentTimeMillis() + "'," + history_id + ")"); if (ins > 0) { System.out.println("inserted"); }/*from ww w. j av a 2 s.com*/ } } catch (Exception e) { e.printStackTrace(); } } } }