當前位置: 首頁>>代碼示例>>Java>>正文


Java JTable.convertRowIndexToView方法代碼示例

本文整理匯總了Java中javax.swing.JTable.convertRowIndexToView方法的典型用法代碼示例。如果您正苦於以下問題:Java JTable.convertRowIndexToView方法的具體用法?Java JTable.convertRowIndexToView怎麽用?Java JTable.convertRowIndexToView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.convertRowIndexToView方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: getPreviousNode

import javax.swing.JTable; //導入方法依賴的package包/類
@Override
public T getPreviousNode (T node) {
    T prev = null;
    if (node != null) {
        int index = Arrays.asList(tableModel.getNodes()).indexOf(node);
        if (index >= 0) {
            JTable table = getTable();
            index = table.convertRowIndexToView(index);
            if (--index >= 0) {
                prev = tableModel.getNodes()[table.convertRowIndexToModel(index)];
            }
        }
    }
    return prev;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:VCSStatusTable.java

示例3: 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

示例4: move

import javax.swing.JTable; //導入方法依賴的package包/類
/**
 * Moves the current selection according to the direction.
 * @param direction the direction to move
 */
public void move(JTable jTable, int direction) {
	
	if (jTable.getSelectedRow()!=-1 && direction!=0) {
		
		int selectedRowTableNew; 
		int selectedRowModelNew;
		int selectedRowTable = jTable.getSelectedRow();
		int selectedRowModel = jTable.convertRowIndexToModel(selectedRowTable);
		
		if (!((selectedRowModel==0 && direction<0) || (selectedRowModel==this.tableModelDataVector.size()-1 && direction>0))) {
			Vector<Number> rowSelected = this.tableModelDataVector.remove(selectedRowModel);
			XyValuePair xyValuePair = (XyValuePair) this.getOntologyModel().removeXyValuePair(this.getFocusedSeriesIndex(), selectedRowModel);
			
			if (direction>0) {
				// --- move down ------------
				selectedRowModelNew = selectedRowTable+1; 
				this.tableModelDataVector.add(selectedRowModelNew, rowSelected);
				this.getOntologyModel().addXyValuePair(this.getFocusedSeriesIndex(), selectedRowModelNew, xyValuePair);
				this.getChartModel().setXYSeriesAccordingToOntologyModel(this.getFocusedSeriesIndex());
				fireTableRowsInserted(selectedRowModel, selectedRowModelNew);
				
			} else {
				// --- move up --------------
				selectedRowModelNew = selectedRowTable-1; 
				this.tableModelDataVector.add(selectedRowModelNew, rowSelected);
				this.getOntologyModel().addXyValuePair(this.getFocusedSeriesIndex(), selectedRowModelNew, xyValuePair);
				this.getChartModel().setXYSeriesAccordingToOntologyModel(this.getFocusedSeriesIndex());
				fireTableRowsInserted(selectedRowModelNew, selectedRowModel);
			}
			
			selectedRowTableNew = jTable.convertRowIndexToView(selectedRowModelNew);
			if(selectedRowTableNew >= 0){
				jTable.setRowSelectionInterval(selectedRowTableNew, selectedRowTableNew);
				jTable.changeSelection(selectedRowTableNew, 0, false, false);
			}
		}
	}
	
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:44,代碼來源:XyTableModel.java

示例5: removeRow

import javax.swing.JTable; //導入方法依賴的package包/類
@Override
public void removeRow(JTable jTable){

	int colIndexTable = jTable.getSelectedColumn();
	int rowIndexTable = jTable.getSelectedRow();
	
	int rowIndexModel = 0;
	int rowIndexTableNew = 0;
	int rowIndexModelNew = 0;
	
	// --- Stop editing -----------------
	if(jTable.isEditing()){
		jTable.getCellEditor().cancelCellEditing();
	}
	
	// ---- Last row of data series? ----
	if(jTable.getRowCount()==1){
		while(parentDataModel.getSeriesCount()>0){
			try {
				parentDataModel.removeSeries(0);
			} catch (NoSuchSeriesException e1) {
				// This cannot happen, as there where clause prevents empty models  
			}
		}
		rowIndexModelNew = -1;
		rowIndexTableNew = -1;
		
	}else{
		
		if ((rowIndexTable+1) > jTable.getRowCount()) {
			rowIndexTable = jTable.getRowCount() - 1;
		}
		Number key = (Number) jTable.getValueAt(rowIndexTable, 0);
		rowIndexModel = jTable.convertRowIndexToModel(rowIndexTable);
		((TimeSeriesDataModel)parentDataModel).removeValuePairsFromAllSeries(key);
		
		rowIndexModelNew = rowIndexModel;
		if (rowIndexModelNew>=jTable.getRowCount()) {
			rowIndexModelNew = jTable.getRowCount()-1;
		}
		rowIndexTableNew = jTable.convertRowIndexToView(rowIndexModelNew);
		
	}
	
	// --- Set new selection ------------
	if(rowIndexTableNew==-1){
		jTable.clearSelection();
	} else {
		jTable.setRowSelectionInterval(rowIndexTableNew, rowIndexTableNew);
		jTable.changeSelection(rowIndexTableNew, colIndexTable, false, false);
	}
	
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:54,代碼來源:TimeSeriesTableModel.java


注:本文中的javax.swing.JTable.convertRowIndexToView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。