List of usage examples for javax.swing JTable getRowCount
@BeanProperty(bound = false) public int getRowCount()
JTable
, given unlimited space. From source file:frameworks.Masken.java
public void maskentranscode(JTable table, String altezd, String neuezd) { int neuezdint = 0; int dbnummerx = 0; for (int i = 0; i < table.getRowCount(); i++) { // Tabelle durchlaufen // Und die Maske erst mal in ZD umrechnen // Schleife ber das Maskenarray der DB for (int dbnummer = 1; dbnummer < 41; dbnummer++) { //Schleife ebr die Gruppen for (int grnummer = 0; grnummer < 21; grnummer++) { // Wenn nun die Maskennummer zur aktuellen Tabellenzeile passt if (GlobalVars.MaskArray[dbnummer][grnummer] != null) { if (GlobalVars.MaskArray[dbnummer][grnummer].equals(table.getValueAt(i, 0))) { // Dann wissen wir die Datei und die GR //die muss aber noch bersetzt werden in Vartab anstatt DB Vartab vartab = new Vartab(); dbnummerx = vartab.ZD2Vartab(dbnummer); //Falls diese mit der bergeben ZD die gendert wurde bereinstimmt if (altezd.equals(Integer.toString(dbnummerx))) { // dann mssen wir diese transferieren int neuezdi = Integer.parseInt(neuezd); neuezdi = vartab.Vartab2ZD(neuezdi); table.setValueAt(GlobalVars.MaskArray[neuezdi][grnummer], i, 1); }/* w ww .java2s. c o m*/ } } } /* dbgr = table.getValueAt(i, 3).toString(); db = dbgr.substring(0, dbgr.indexOf(":")); gr = dbgr.substring(dbgr.indexOf(":") + 1, dbgr.length()); if (db.equals(altezd)) { table.setValueAt(neuezd + ":" + gr, i, 3);*/ } } }
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.table.JTableInfoForCMFile.java
synchronized public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);/*from ww w . ja va 2 s .c om*/ if (value == null) { comp.setToolTipText(null); return comp; } comp.setToolTipText(String.valueOf(value)); if (row >= table.getRowCount()) { log.debug("row > table.getRowCount()"); return comp; } switch (column) { case TableModelForCMFile.COL_COMPONENT_NAME: case TableModelForCMFile.COL_LICENSE_NAME: setHorizontalAlignment(SwingConstants.LEFT); break; case TableModelForCMFile.COL_VERSION_NAME: case TableModelForCMFile.COL_USAGE: case TableModelForCMFile.COL_STATUS: case TableModelForCMFile.COL_PERCENTAGE: case TableModelForCMFile.COL_MATCHED_FILE: setHorizontalAlignment(SwingConstants.CENTER); break; } if (table.getValueAt(row, TableModelForCMFile.COL_STATUS) == null) return comp; String status = table.getValueAt(row, TableModelForCMFile.COL_STATUS).toString(); String licenseName = table.getValueAt(row, TableModelForCMFile.COL_LICENSE_NAME).toString(); if (status.equals(AbstractMatchInfo.IDENTIFIED)) { comp.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 12)); comp.setForeground(NORMAL_COLOR); } else if ((status.equals(AbstractMatchInfo.REJECTED)) || (status.equals(AbstractMatchInfo.DECLARED))) { comp.setForeground(new Color(150, 150, 150)); } else if (status.equals(AbstractMatchInfo.PENDING)) { if (identifiedStringSearchLicense != null && !identifiedStringSearchLicense.equals("")) { String currentRowLicense = "" + licenseName; if (identifiedStringSearchLicense.equals(currentRowLicense)) { comp.setForeground(NORMAL_COLOR); } else { comp.setForeground(GRAY_COLOR); } } else { comp.setForeground(NORMAL_COLOR); } } return comp; }
From source file:net.sf.jabref.importer.ZipFileChooser.java
/** * New Zip file chooser.//from ww w. ja v a 2s. c om * * @param owner Owner of the file chooser * @param zipFile Zip-Fle to choose from, must be readable */ public ZipFileChooser(ImportCustomizationDialog importCustomizationDialog, ZipFile zipFile) { super(importCustomizationDialog, Localization.lang("Select file from ZIP-archive"), false); ZipFileChooserTableModel tableModel = new ZipFileChooserTableModel(zipFile, getSelectableZipEntries(zipFile)); JTable table = new JTable(tableModel); TableColumnModel cm = table.getColumnModel(); cm.getColumn(0).setPreferredWidth(200); cm.getColumn(1).setPreferredWidth(150); cm.getColumn(2).setPreferredWidth(100); JScrollPane sp = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setPreferredScrollableViewportSize(new Dimension(500, 150)); if (table.getRowCount() > 0) { table.setRowSelectionInterval(0, 0); } // cancel: no entry is selected JButton cancelButton = new JButton(Localization.lang("Cancel")); cancelButton.addActionListener(e -> dispose()); // ok: get selected class and check if it is instantiable as an importer JButton okButton = new JButton(Localization.lang("OK")); okButton.addActionListener(e -> { int row = table.getSelectedRow(); if (row == -1) { JOptionPane.showMessageDialog(this, Localization.lang("Please select an importer.")); } else { ZipFileChooserTableModel model = (ZipFileChooserTableModel) table.getModel(); ZipEntry tempZipEntry = model.getZipEntry(row); CustomImporter importer = new CustomImporter(); importer.setBasePath(model.getZipFile().getName()); String className = tempZipEntry.getName().substring(0, tempZipEntry.getName().lastIndexOf('.')) .replace("/", "."); importer.setClassName(className); try { ImportFormat importFormat = importer.getInstance(); importer.setName(importFormat.getFormatName()); importer.setCliId(importFormat.getId()); importCustomizationDialog.addOrReplaceImporter(importer); dispose(); } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException exc) { LOGGER.warn("Could not instantiate importer: " + importer.getName(), exc); JOptionPane.showMessageDialog(this, Localization.lang("Could not instantiate %0 %1", importer.getName() + ":\n", exc.getMessage())); } } }); // Key bindings: JPanel mainPanel = new JPanel(); //ActionMap am = mainPanel.getActionMap(); //InputMap im = mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); //im.put(Globals.getKeyPrefs().getKey(KeyBinds.CLOSE_DIALOG), "close"); //am.put("close", closeAction); mainPanel.setLayout(new BorderLayout()); mainPanel.add(sp, BorderLayout.CENTER); JPanel optionsPanel = new JPanel(); optionsPanel.add(okButton); optionsPanel.add(cancelButton); optionsPanel.add(Box.createHorizontalStrut(5)); getContentPane().add(mainPanel, BorderLayout.CENTER); getContentPane().add(optionsPanel, BorderLayout.SOUTH); this.setSize(getSize()); pack(); this.setLocationRelativeTo(importCustomizationDialog); new FocusRequester(table); }
From source file:com.vgi.mafscaling.Rescale.java
private boolean getMafTableData(JTable mafTable, ArrayList<Double> voltArray, ArrayList<Double> gsArray) { String value;//from ww w .j a v a2 s.co m for (int i = 0; i < mafTable.getColumnCount(); ++i) { for (int j = 0; j < mafTable.getRowCount(); ++j) { value = mafTable.getValueAt(j, i).toString(); if (value.isEmpty()) return true; if (!Utils.validateDouble(value, j, i, mafTable.getName())) return false; } voltArray.add(Double.parseDouble(mafTable.getValueAt(0, i).toString())); gsArray.add(Double.parseDouble(mafTable.getValueAt(1, i).toString())); } if (voltArray.size() != gsArray.size()) { JOptionPane.showMessageDialog(null, "Data sets (volt/gs) in " + mafTable.getName() + " have different length", "Invalid Data", JOptionPane.ERROR_MESSAGE); return false; } return true; }
From source file:edu.ucla.stat.SOCR.chart.SuperHistogramChart.java
/** * reset dataTable to default (demo data), and refesh chart *//* w w w . j a va 2s . c o m*/ public void resetExample() { reset_BinSlider(); IntervalXYDataset dataset = createDataset(true); JFreeChart chart = createChart(dataset); chartPanel = new ChartPanel(chart, false); setChart(); hasExample = true; convertor.Y2Table(raw_x, row_count); //convertor.dataset2Table(dataset); JTable tempDataTable = convertor.getTable(); resetTableRows(tempDataTable.getRowCount() + 1); resetTableColumns(tempDataTable.getColumnCount()); for (int i = 0; i < tempDataTable.getColumnCount(); i++) { columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i)); // System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i)); } columnModel = dataTable.getColumnModel(); dataTable.setTableHeader(new EditableHeader(columnModel)); for (int i = 0; i < tempDataTable.getRowCount(); i++) for (int j = 0; j < tempDataTable.getColumnCount(); j++) { dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j); } dataPanel.removeAll(); dataPanel.add(new JScrollPane(dataTable)); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); dataTable.doLayout(); // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003 try { dataTable.setDragEnabled(true); } catch (Exception e) { } dataPanel.validate(); // do the mapping setMapping(); updateStatus(url); }
From source file:edu.ucla.stat.SOCR.chart.SuperPieChart.java
/** * reset dataTable to default (demo data), and refesh chart *//*from ww w. j a v a2s . c om*/ public void resetExample() { isDemo = true; dataset = createDataset(true); JFreeChart chart = createChart(dataset); chartPanel = new ChartPanel(chart, false); setChart(); hasExample = true; if (!ThreeDPie) convertor.dataset2Table(dataset, pulloutFlag); else convertor.dataset2Table(dataset); JTable tempDataTable = convertor.getTable(); // resetTable(); resetTableRows(tempDataTable.getRowCount() + 1); resetTableColumns(tempDataTable.getColumnCount() + 1); for (int i = 0; i < tempDataTable.getColumnCount(); i++) { columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i)); // System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i)); } columnModel = dataTable.getColumnModel(); dataTable.setTableHeader(new EditableHeader(columnModel)); for (int i = 0; i < tempDataTable.getRowCount(); i++) for (int j = 0; j < tempDataTable.getColumnCount(); j++) { dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j); //System.out.println("setting dataTable :"+tempDataTable.getValueAt(i,j)); } dataPanel.removeAll(); dataPanel.add(new JScrollPane(dataTable)); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); dataTable.doLayout(); // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003 try { dataTable.setDragEnabled(true); } catch (Exception e) { } dataPanel.validate(); // do the mapping setMapping(); updateStatus(url); }
From source file:com.smanempat.controller.ControllerEvaluation.java
private String[] getJurusanTest(JTable tableTahunTesting, JTable tableDataSetTesting) throws SQLException { String[] returnValue = new String[tableDataSetTesting.getRowCount()]; int row;// w w w.j a v a2 s . co m row = tableTahunTesting.getRowCount(); boolean checkList; int j = 0; for (int i = 0; i < row; i++) { checkList = Boolean.valueOf("" + tableTahunTesting.getValueAt(i, 1)); if (checkList == true) { dbConnection = new DbConnection(); connect = dbConnection.connect(); query = "SELECT * FROM siswa WHERE tahun_ajaran = ?"; pstmt = connect.prepareStatement(query); pstmt.setString(1, tableTahunTesting.getValueAt(i, 0).toString()); rs = pstmt.executeQuery(); while (rs.next()) { returnValue[j] = rs.getString("jurusan"); j++; } } } return returnValue; }
From source file:com.smanempat.controller.ControllerEvaluation.java
public void validasiNumberofNearest(KeyEvent evt, JTextField txtNumberOfK, JLabel labelPesanError, JTable tableDataSetModel) { String numberValidate = txtNumberOfK.getText(); int modelRow = tableDataSetModel.getRowCount(); if (Pattern.matches("[0-9]+", numberValidate) == false && numberValidate.length() > 0) { evt.consume();//www. ja v a 2 s. c o m labelPesanError.setText("Number of Nearest Neighbor tidak valid"); } else if (numberValidate.length() == 9) { evt.consume(); labelPesanError.setText("Number of Nearest Neighbor terlalu panjang"); } else { labelPesanError.setText(""); } }
From source file:GeMSE.GS.Analysis.Stats.OneSampleCovariancePanel.java
public void ResizeColumnWidth(JTable table) { final TableColumnModel columnModel = table.getColumnModel(); for (int column = 0; column < table.getColumnCount(); column++) { int width = 50; // Min width TableColumn tableColumn = columnModel.getColumn(column); TableCellRenderer renderer = tableColumn.getHeaderRenderer(); if (renderer == null) renderer = table.getTableHeader().getDefaultRenderer(); Component component = renderer.getTableCellRendererComponent(table, tableColumn.getHeaderValue(), false, false, -1, column);//from w ww.j a va2 s .c o m width = Math.max(component.getPreferredSize().width + 5, width); for (int row = 0; row < table.getRowCount(); row++) { renderer = table.getCellRenderer(row, column); Component comp = table.prepareRenderer(renderer, row, column); width = Math.max(comp.getPreferredSize().width + 5, width); } if (width > 400) width = 400; columnModel.getColumn(column).setPreferredWidth(width); } }
From source file:maltcms.ui.fileHandles.csv.CSVTableView.java
private HashMap<String, Integer> getLabelToIndex(JTable jt, int labelColumn) { HashSet<String> hm = new LinkedHashSet<>(); for (int i = 0; i < jt.getRowCount(); i++) { hm.add(String.valueOf(jt.getModel().getValueAt(i, labelColumn))); }/* w ww.ja v a 2s . c om*/ HashMap<String, Integer> placeMap = new LinkedHashMap<>(); int cnt = 0; for (String s : hm) { Logger.getLogger(getClass().getName()).log(Level.INFO, "Label: {0}", s); placeMap.put(s, cnt++); } return placeMap; }