List of usage examples for javax.swing.table DefaultTableModel setColumnIdentifiers
public void setColumnIdentifiers(Object[] newIdentifiers)
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 w w .j av a 2 s .c om // } // 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:sms.ViewResults.java
public void counter(int count) { DefaultTableModel model = new DefaultTableModel(); String[] c = { "count" }; model.setColumnIdentifiers(c); Object[] row = new Object[1]; for (int a = 1; a <= count; a++) { row[0] = a;/*from w ww . j ava 2 s . com*/ model.addRow(row); } this.tblCounter.setModel(model); }