当前位置: 首页>>代码示例>>Java>>正文


Java JTable.getRowCount方法代码示例

本文整理汇总了Java中javax.swing.JTable.getRowCount方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.getRowCount方法的具体用法?Java JTable.getRowCount怎么用?Java JTable.getRowCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.getRowCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resizeColumnWidth

import javax.swing.JTable; //导入方法依赖的package包/类
public void resizeColumnWidth(JTable table) {
    final TableColumnModel columnModel = table.getColumnModel();
    for (int column = 0; column < table.getColumnCount(); column++) {
        int width = 50; // Min width
        for (int row = 0; row < table.getRowCount(); row++) {
            TableCellRenderer renderer = table.getCellRenderer(row, column);
            Component comp = table.prepareRenderer(renderer, row, column);
            width = Math.max(comp.getPreferredSize().width, width);
        }
        columnModel.getColumn(column).setPreferredWidth(width);
        columnModel.getColumn(column).setMinWidth(minColumnWidths[column]);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CoverageReportTopComponent.java

示例2: getNextNode

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public T getNextNode (T node) {
    T next = null;
    if (node != null) {
        int index = Arrays.asList(tableModel.getNodes()).indexOf(node);
        if (index >= 0) {
            JTable table = getTable();
            index = table.convertRowIndexToView(index);
            if (++index < table.getRowCount()) {
                next = tableModel.getNodes()[table.convertRowIndexToModel(index)];
            }
        }
    }
    return next;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:VCSStatusTable.java

示例3: RowNumberTable

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Constructor to create a new {@link RowNumberTable} instance.
 *
 * @param contentTable
 *            the table the {@link RowNumberTable} should be created for
 */
public RowNumberTable(final JTable contentTable) {
	this.contentTable = contentTable;
	contentTable.addPropertyChangeListener(listener);

	setFocusable(false);
	setAutoCreateColumnsFromModel(false);

	TableColumn column = new TableColumn();
	column.setCellRenderer(new RowNumberRenderer());
	addColumn(column);

	// calculate preferred width dynamically
	int rowCount = contentTable.getRowCount();
	preferredWidth = 25;
	if (rowCount > 0) {
		preferredWidth = 15 + 6 * String.valueOf(rowCount).length();
	}
	getColumnModel().getColumn(0).setPreferredWidth(preferredWidth);
	setPreferredScrollableViewportSize(getPreferredSize());
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:RowNumberTable.java

示例4: checkforduplicaterow

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * check whether the  <code>row</code> present or not
 *
 * @param table target table
 * @param row target row
 * @return  <code>true</code> if present else <code>false</code>
 */
static boolean checkforduplicaterow(JTable table, Object[] row) {
    String value = "", value1 = "";
    int cRow = table.getRowCount(), cCol = table.getColumnCount();
    for (Object cell : row) {
        value1 += cell != null ? cell.toString() : "";
    }
    for (int i = 0; i < cRow; i++) {
        for (int j = 0; j < cCol; j++) {
            Object tmp = table.getModel().getValueAt(i, j);
            if (j == 4) {
                tmp = "NoRun";
            }
            value += tmp != null ? tmp.toString() : "";
        }
        if (value.equals(value1)) {
            return true;
        }
        value = "";
    }
    return false;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:29,代码来源:JtableUtils.java

示例5: packColumn

import javax.swing.JTable; //导入方法依赖的package包/类
private static void packColumn(JTable table, int vColIndex, int margin) {
    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.
            getColumnModel();
    TableColumn col = colModel.getColumn(vColIndex);
    int width;            // Obtém a largura do cabeçalho da coluna
    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null) {
        renderer = table.getTableHeader().getDefaultRenderer();
    }
    Component comp = renderer.getTableCellRendererComponent(
            table, col.getHeaderValue(), false, false, 0, 0);
    width = comp.getPreferredSize().width;            // Obtém a largura maxima da coluna de dados
    for (int r = 0; r < table.getRowCount(); r++) {
        renderer = table.getCellRenderer(r, vColIndex);
        comp = renderer.getTableCellRendererComponent(
                table, table.getValueAt(r, vColIndex), false, false, r,
                vColIndex);
        width = Math.max(width, comp.getPreferredSize().width);
    }
    width += 2 * margin;            // Configura a largura
    col.setPreferredWidth(width);
}
 
开发者ID:karlos7,项目名称:ViolenciaContraMulher,代码行数:23,代码来源:FormataTamanhoColunasJTable.java

示例6: setSelectedRow

import javax.swing.JTable; //导入方法依赖的package包/类
private void setSelectedRow(JTable table, Object selectedObject, int objectColumn) {
    if(table==null || selectedObject==null || objectColumn==-1)return;
    //after move to java6 as minimum requirent for nb may consider to replace with JTable::convertRowIndexToModel and back
    //current mplementation works with java5
    TableModel model = table.getModel();
    int rowCount=table.getRowCount();
    for(int i=0; i<rowCount; i++) {
        if(selectedObject.equals(model.getValueAt(i, objectColumn))) {
            table.setRowSelectionInterval(i, i);
            table.scrollRectToVisible(table.getCellRect(i, objectColumn, true));
            break;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:TableSorter.java

示例7: canImport

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Called to allow drop operations, allow driver drag full range of rows
 * except for last (Add driver box).
 */
@Override
public boolean canImport(TransferHandler.TransferSupport support)
{
	JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation();
	JTable target = (JTable)support.getComponent();

	if (dl.getRow() > target.getRowCount()) return false;
	return true;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:14,代码来源:DriverTable.java

示例8: putTestData

import javax.swing.JTable; //导入方法依赖的package包/类
private void putTestData(JTable table, int row) {
    TestCase testCase = (TestCase) table.getModel();
    testCase.startGroupEdit();
    TestDataDetail td = (TestDataDetail) dropObject;
    for (String col : td.getColumnNames()) {
        if (row > table.getRowCount() - 1) {
            testCase.addNewStep();
        }
        table.setValueAt(td.getSheetName() + ":" + col, row++, inputColumn);
    }
    testCase.stopGroupEdit();
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:TestCaseTableDnD.java

示例9: addEmptyRow

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void addEmptyRow(JTable jTable){
	
	// --- Get current position in the table model ----
	Vector<Number> rowSelected = null;
	Vector<Number> newRow = null;
	long currKey = 0L;
	long newKey = 0L;
	float newValue = 0f;
	
	// --- Get the current or the last row ------------
	int modelLineSelected = 0;
	int modelLineSelectedNew = 0;
	int tableRowSelected = 0;
	int tableRowSelectedNew = 0;
		
	tableRowSelected = jTable.getSelectedRow();
	if (tableRowSelected==-1 || tableRowSelected>=jTable.getRowCount()) {
		tableRowSelected = jTable.getRowCount()-1;
	}
	
	if (tableModelDataVector.size()==0) {
		// --- Create new data series -------
		DataSeries newSeries = parentDataModel.createNewDataSeries(parentDataModel.getDefaultSeriesLabel());
		
		ValuePair initialValuePair = parentDataModel.createNewValuePair(0L, newValue);
		parentDataModel.getValuePairsFromSeries(newSeries).add(initialValuePair);
		parentDataModel.addSeries(newSeries);
		
	} else {
		// --- Get current selection --------
		modelLineSelected = jTable.convertRowIndexToModel(tableRowSelected);
		rowSelected = tableModelDataVector.get(modelLineSelected);
		currKey = (Long) rowSelected.get(tableModelDataVector.getKeyColumnIndex());
		
		// --- Find a new key value ---------
		newKey = currKey + 1L;
		while (tableModelDataVector.getKeyRowVectorTreeMap().get(newKey)!=null) {
			newKey = newKey + 1L;
		}
		
		// --- Find new index position ------
		modelLineSelectedNew = tableModelDataVector.size();
		for (int i=0; i < tableModelDataVector.size(); i++) {
			Vector<Number> row = tableModelDataVector.get(i);
			long key = (Long) row.get(0);
			if (key>newKey) {
				modelLineSelectedNew = i;
				break;
			}
		}
		
		// --- Add new row data -------------
		newRow = new Vector<Number>();
		newRow.add(newKey);
		for(int i=1; i<getColumnCount(); i++){
			newRow.add(newValue);
			try {
				this.getChartModel().addOrUpdateValuePair(i-1, newKey, newValue);
				this.getOntologyModel().addOrUpdateValuePair(i-1, newKey, newValue);
				
			} catch (NoSuchSeriesException e) {
				e.printStackTrace();
			}
		}
		// --- Add new row to table model ---
		tableModelDataVector.add(modelLineSelectedNew, newRow);
		
	}
	fireTableRowsInserted(0, getRowCount()-1);
	
	// --- Set new selection ----------------
	tableRowSelectedNew = jTable.convertRowIndexToView(modelLineSelectedNew);
	if(tableRowSelectedNew >= 0){
		jTable.setRowSelectionInterval(tableRowSelectedNew, tableRowSelectedNew);
		jTable.changeSelection(tableRowSelectedNew, 0, false, false);
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:79,代码来源:TimeSeriesTableModel.java

示例10: getTableData

import javax.swing.JTable; //导入方法依赖的package包/类
private List<HashMap<String, String>> getTableData(JTable table) {
    List<HashMap<String, String>> data = new ArrayList<>();
    HashMap<String, String> row;
    JtableUtils.removeEmptyRows(table);
    int rowCount = table.getRowCount(), i;
    for (i = 0; i < rowCount; i++) {
        row = new HashMap<>();
        Object val = table.getValueAt(i, 1);
        row.put("moduleId", (val == null) ? "" : val.toString());
        data.add(row);
    }
    return data;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:14,代码来源:SettingsUI.java

示例11: updateNumPeople

import javax.swing.JTable; //导入方法依赖的package包/类
public void updateNumPeople(JScrollPane j,JTable t,JLabel l,int index){
    for(int k = 0 ; k<numPplPerRoom.length ; k++){
        numPplPerRoom[k]=0;
    }
    if(j.isVisible()){
        for(int i = 0; i < t.getRowCount();i++){
            numPplPerRoom[index] += Integer.parseInt(t.getModel().getValueAt(i, 1).toString());
        }
        l.setText((String.valueOf(numPplPerRoom[index])));
    }
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-N,代码行数:12,代码来源:GuiPrincipale.java

示例12: _getText

import javax.swing.JTable; //导入方法依赖的package包/类
@Override public String _getText() {
    JTable table = (JTable) getComponent();
    int rows = table.getRowCount();
    int cols = table.getColumnCount();
    JSONArray r = new JSONArray();
    for (int i = 0; i < rows; i++) {
        JSONArray c = new JSONArray();
        for (int j = 0; j < cols; j++) {
            c.put(new JTableCellJavaElement(JTableJavaElement.this, i, j)._getText());
        }
        r.put(c);
    }
    return r.toString();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:JTableJavaElement.java

示例13: moverowdown

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Moves the selected nullRoww one nullRoww DOWN., unless it is the last
 * nullRoww
 *
 * @param table the target tmodel
 */
public static void moverowdown(JTable table) {
    int sRow = table.getSelectedRow();
    if (sRow < table.getRowCount() - 1 && sRow >= 0) {
        ((DefaultTableModel) table.getModel()).moveRow(sRow, sRow, sRow + 1);
        table.getSelectionModel().setSelectionInterval(sRow + 1, sRow + 1);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:14,代码来源:JtableUtils.java

示例14: printDebugData

import javax.swing.JTable; //导入方法依赖的package包/类
private void printDebugData(JTable table) {
    int numRows = table.getRowCount();
    int numCols = table.getColumnCount();
    javax.swing.table.TableModel model = table.getModel();

    System.out.println("Value of data: ");
    for (int i = 0; i < numRows; i++) {
        System.out.print("    row " + i + ":");
        for (int j = 0; j < numCols; j++) {
            System.out.print("  " + model.getValueAt(i, j));
        }
        System.out.println();
    }
    System.out.println("--------------------------");
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:16,代码来源:SimpleTableSelectionDemo.java

示例15: getPropertiesFromTable

import javax.swing.JTable; //导入方法依赖的package包/类
public static Properties getPropertiesFromTable(Properties x, JTable table) {
    JtableUtils.stopEditing(table);
    int rowcount = table.getRowCount();
    for (int i = 0; i < rowcount; i++) {
        String prop = getString(table.getValueAt(i, 0));
        String val = getString(table.getValueAt(i, 1));
        if (!prop.isEmpty()) {
            x.setProperty(prop, val);
        }
    }
    return x;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:PropUtils.java


注:本文中的javax.swing.JTable.getRowCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。