List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:dk.i2m.netbeans.modules.ldapexplorer.ui.ExplorerTopComponent.java
private void addRow(DefaultTableModel model, String att, Object val) { final String LBL_PREFIX = "ATTRIBUTE_FRIENDLY_NAME_"; String attName = att;/* w ww.j a v a2 s. c o m*/ if (bundle.containsKey(LBL_PREFIX + att.toLowerCase())) { attName = bundle.getString(LBL_PREFIX + att.toLowerCase()); } if (val instanceof byte[]) { // Field is binary - convert it to hexadecimals model.addRow(new Object[] { attName, att, Hex.encodeHexString((byte[]) val) }); } else { model.addRow(new Object[] { attName, att, val }); } }
From source file:aasdntool.AASDNTool.java
private void devicesActionPerformed(java.awt.event.ActionEvent evt) { StringBuffer response = new StringBuffer(); try {/*from w w w. j av a 2 s. c o m*/ URL obj = new URL("http://" + controllerIP + ":8080/wm/device/"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); // optional default is GET con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); System.out.println("\nSending 'GET' request to URL : " + "http://" + controllerIP + ":8080/wm/device/"); System.out.println("Response Code : " + responseCode); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); ObjectMapper mapper = new ObjectMapper(); List<Device> devList = mapper.readValue(response.toString(), mapper.getTypeFactory().constructCollectionType(List.class, Device.class)); DefaultTableModel dtm = new DefaultTableModel(0, 0); // add header of the table String header[] = new String[] { "MAC Address" }; // add header in table model dtm.setColumnIdentifiers(header); macTable.setModel(dtm); for (Device dev : devList) { dtm.addRow(new Object[] { dev.getMac() }); } } catch (Exception e) { System.out.println("Exception occured:" + e); } }
From source file:tp1.G_AdminStats.java
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowGainedFocus // TODO add your handling code here: Map<String, Integer> att = new HashMap<String, Integer>(); DefaultTableModel model = (DefaultTableModel) tab3.getModel(); model.setRowCount(0);/*from w ww . j av a2s. c o m*/ try { Class.forName("java.sql.DriverManager"); Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/projectbuy", "root", "null"); Statement stmt = (Statement) con.createStatement(); String query = "SELECT usr, count(DISTINCT Datee) FROM attendence GROUP BY usr;"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { String a = rs.getString(1); String b = rs.getString(2); model.addRow(new Object[] { a, b }); att.put(a, Integer.parseInt(b)); } } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getMessage()); } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Map.Entry<String, Integer> entry : att.entrySet()) { dataset.addValue(entry.getValue(), "series1", entry.getKey()); } JFreeChart chart = ChartFactory.createBarChart("Attendence", "Admin Name", "Days Present", dataset, PlotOrientation.VERTICAL, false, true, false); try { BufferedImage chartImage = chart.createBufferedImage(800, 300, null); labelGraph.setIcon(new javax.swing.ImageIcon(chartImage)); } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:gtu._work.etc.GoogleContactUI.java
void googleTableMouseClicked(MouseEvent evt) { try {/*from w ww . ja v a 2 s. co m*/ JPopupMenuUtil popupUtil = JPopupMenuUtil.newInstance(googleTable).applyEvent(evt); //CHANGE ENCODE popupUtil.addJMenuItem("set encode", new ActionListener() { public void actionPerformed(ActionEvent e) { try { String code = StringUtils.defaultString(JOptionPaneUtil.newInstance().iconPlainMessage() .showInputDialog("input file encode", "ENCODE"), "UTF8"); encode = Charset.forName(code).displayName(); } catch (Exception ex) { JCommonUtil.handleException(ex); } System.err.println("encode : " + encode); } }); //SIMPLE LOAD GOOGLE CSV FILE popupUtil.addJMenuItem("open Google CSV file", new ActionListener() { public void actionPerformed(ActionEvent e) { File file = JFileChooserUtil.newInstance().selectFileOnly().addAcceptFile("csv", ".csv") .showOpenDialog().getApproveSelectedFile(); if (file == null) { errorMessage("file is not correct!"); return; } try { if (file.getName().endsWith(".csv")) { DefaultTableModel model = (DefaultTableModel) googleTable.getModel(); LineNumberReader reader = new LineNumberReader( new InputStreamReader(new FileInputStream(file), GOOGLE_CVS_ENCODE)); for (String line = null; (line = reader.readLine()) != null;) { if (reader.getLineNumber() == 1) { continue; } model.addRow(line.split(",")); } reader.close(); googleTable.setModel(model); JTableUtil.newInstance(googleTable).hiddenAllEmptyColumn(); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); //SAVE CSV FILE FOR GOOGLE popupUtil.addJMenuItem("save to Google CVS file", new ActionListener() { public void actionPerformed(ActionEvent e) { File file = JFileChooserUtil.newInstance().selectFileOnly().addAcceptFile(".csv", ".csv") .showSaveDialog().getApproveSelectedFile(); if (file == null) { errorMessage("file is not correct!"); return; } file = FileUtil.getIndicateFileExtension(file, ".csv"); try { BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(file), GOOGLE_CVS_ENCODE)); StringBuilder sb = new StringBuilder(); for (Object title : googleColumns) { sb.append(title + ","); } sb.deleteCharAt(sb.length() - 1); System.out.println(sb); writer.write(sb.toString()); writer.newLine(); DefaultTableModel model = (DefaultTableModel) googleTable.getModel(); for (int row = 0; row < model.getRowCount(); row++) { sb = new StringBuilder(); for (int col = 0; col < model.getColumnCount(); col++) { String colVal = StringUtils.defaultString((String) model.getValueAt(row, col), ""); if (colVal.equalsIgnoreCase("null")) { colVal = ""; } sb.append(colVal + ","); } sb.deleteCharAt(sb.length() - 1); System.out.println(sb); writer.write(sb.toString()); writer.newLine(); } writer.flush(); writer.close(); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); //PASTE CLIPBOARD popupUtil.addJMenuItem("paste clipboard", new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { JTableUtil.newInstance(googleTable).pasteFromClipboard_multiRowData(true); } }); popupUtil.addJMenuItem("paste clipboard to selected cell", new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { JTableUtil.newInstance(googleTable).pasteFromClipboard_singleValueToSelectedCell(); } }); JMenuItem addEmptyRowItem = JTableUtil.newInstance(googleTable).jMenuItem_addRow(false, "add row count?"); addEmptyRowItem.setText("add row"); JMenuItem removeColumnItem = JTableUtil.newInstance(googleTable).jMenuItem_removeColumn(null); removeColumnItem.setText("remove column"); JMenuItem removeRowItem = JTableUtil.newInstance(googleTable).jMenuItem_removeRow(null); removeRowItem.setText("remove row"); JMenuItem removeAllRowItem = JTableUtil.newInstance(googleTable) .jMenuItem_removeAllRow("remove all row?"); removeAllRowItem.setText("remove all row"); JMenuItem clearSelectedCellItem = JTableUtil.newInstance(googleTable) .jMenuItem_clearSelectedCell("are you sure clear selected area?"); clearSelectedCellItem.setText("clear selected area"); popupUtil.addJMenuItem(addEmptyRowItem, removeColumnItem, removeRowItem, removeAllRowItem, clearSelectedCellItem); popupUtil.show(); } catch (Exception ex) { JCommonUtil.handleException(ex); } }
From source file:com.wesley.urban_cuts.client.urbancuts.myFrame.java
private void populate_table() { String data1;//from www. j ava2 s. c o m String data2; String data3; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); List<Payment> allPayments = paymentCrudService.findAll(); if (allPayments != null) { for (int i = 0; i < paymentCrudService.count(); i++) { if (0 == allPayments.get(i).getDate().toString().compareTo(dateFormat.format(date))) { data1 = allPayments.get(i).getBarber_name(); data2 = allPayments.get(i).getStyle_name(); data3 = Double.toString(allPayments.get(i).getPrice()); DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); Object[] row = { data1, data2, data3 }; model.addRow(row); } } } }
From source file:userInterface.doctor.ReportingPatientVitalHistJPanel.java
public void populateVitalTable() { nameJTextField.setText(patient.getName()); idJTextField.setText(patient.getId()); DefaultTableModel dtm = (DefaultTableModel) vitalJTable.getModel(); dtm.setRowCount(0);//from w ww. java2 s . com Object row[] = new Object[6]; for (VitalSignInfo vitalInfo : patient.getVitalHistory().getVitalHistory()) { row[0] = vitalInfo.getRespRate(); row[1] = vitalInfo.getHeartRate(); row[2] = vitalInfo.getSystolicBP(); row[3] = vitalInfo.getWeight(); row[4] = vitalInfo.getCurrentTime(); row[5] = vitalInfo.getSensorId(); dtm.addRow(row); } }
From source file:UserInterface.Doctor.DoctorWorkAreaJPanel.java
public void populateTable() { DefaultTableModel dtm = (DefaultTableModel) tblWorkRequest.getModel(); dtm.setRowCount(0);// www . j ava 2s . c o m for (WorkRequest request : account.getWorkQueue().getWorkRequestList()) { request1 = (PatientDoctorWorkRequest) request; if (!request1.getStatus().equals("Task completed")) { Object[] row = new Object[3]; row[0] = request1; row[1] = request1.getAssignedPatient(); row[2] = request1.getStatus(); dtm.addRow(row); lbl1.setText("Welcome " + request1.getAssignedDoctor().getFirstName()); } } }
From source file:gdt.jgui.tool.JEntityEditor.java
private void addRow() { try {/* w w w . j ava2 s . c o m*/ JScrollPane scrollPane = (JScrollPane) tabbedPane.getSelectedComponent(); JTable table = (JTable) scrollPane.getViewport().getView(); DefaultTableModel model = (DefaultTableModel) table.getModel(); model.addRow(new String[] { null, "Name" + String.valueOf(model.getRowCount()), "Value" }); } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:UserInterface.AdministrativeRole.FeedBackJPanel.java
public void populateTable() { DefaultTableModel model = (DefaultTableModel) feedBackTable.getModel(); model.setRowCount(0);/*from w w w. j a va 2 s. co m*/ for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof AdminOrganization) { for (FarmerFeedbackWorkRequest request : organization.getFeedbackWorkQueue() .getFarmerFeedbackList()) { Object[] row = new Object[2]; row[0] = request; row[1] = request.getDateFiled(); model.addRow(row); } break; } } }
From source file:UserInterface.WaterSupplyAdmin.UsagePatternJPanel.java
private void populateCustomers() { DefaultTableModel model = (DefaultTableModel) customerTable.getModel(); model.setRowCount(0);//w w w .ja v a 2 s.c o m if (customerOrganization != null) { for (Employee employee : customerOrganization.getEmployeeDirectory().getEmployeeList()) { Object[] row = new Object[4]; Customer cust = (Customer) employee; row[0] = cust.getId(); row[1] = cust; row[2] = cust.getContactNo(); row[3] = cust.getEmailId(); model.addRow(row); } note.setText(""); } else { note.setText("*Note : No Customers Available"); } }