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


Java JTable.getSelectedRow方法代码示例

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


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

示例1: actionPerformed

import javax.swing.JTable; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent ae) {
    JTable jt = (JTable) ae.getSource();
    int row = jt.getSelectedRow();
    int col = jt.getSelectedColumn();

    if ((row != -1) && (col != -1)) {
        if (PropUtils.isLoggable(BaseTable.class)) {
            PropUtils.log(BaseTable.class, "Starting edit due to key event for row " + row); //NOI18N
        }

        jt.editCellAt(row, 1, null);

        //Focus will be rerouted to the editor via this call:
        jt.requestFocus();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:BaseTable.java

示例2: rightClick

import javax.swing.JTable; //导入方法依赖的package包/类
public void rightClick(JTable jtable, java.awt.event.MouseEvent evt ){
    try {
        impostaMenu();
    } catch (SQLException ex) {
        Logger.getLogger(GuiPrincipale.class.getName()).log(Level.SEVERE, null, ex);
    }
    if(SwingUtilities.isRightMouseButton(evt)){
        
      int[] coordinate = coordinateMouse(jtable);
      
       jMenuPrincipale.show(this, coordinate[0]+evt.getX(), coordinate[1]+evt.getY());
    }
    try{
        int i = jtable.getSelectedRow();        
        id = Integer.parseInt(jtable.getValueAt(i, 2).toString());
        nomePrenotazione = (String) jtable.getValueAt(i, 0);
    }catch(ArrayIndexOutOfBoundsException s){}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-N,代码行数:19,代码来源:GuiPrincipale.java

示例3: RTable

import javax.swing.JTable; //导入方法依赖的package包/类
public RTable(Component source, JSONOMapConfig omapConfig, Point point, IJSONRecorder recorder) {
    super(source, omapConfig, point, recorder);
    JTable table = (JTable) source;
    if (table.isEditing()) {
        column = table.getEditingColumn();
        row = table.getEditingRow();
    } else {
        if (point != null) {
            row = table.rowAtPoint(point);
            column = table.columnAtPoint(point);
        } else {
            row = table.getSelectedRow();
            column = table.getSelectedColumn();
        }
    }
    if (row == -1 || column == -1) {
        row = column = -1;
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:RTable.java

示例4: getEncryptAction

import javax.swing.JTable; //导入方法依赖的package包/类
private static AbstractAction getEncryptAction(final JTable table) {
    return new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent me) {
            try {
                int col = table.getSelectedColumn();
                int row = table.getSelectedRow();
                if (col > -1 && row > -1) {
                    String data = table.getValueAt(row, col).toString();
                    table.setValueAt(TMIntegration.encrypt(data), row, col);
                }
            } catch (HeadlessException ex) {
                Logger.getLogger(TMSettingsControl.class.getName())
                        .log(Level.SEVERE, ex.getMessage(), ex);
            }

        }
    };
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:20,代码来源:TMSettingsControl.java

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

示例6: keyPressed

import javax.swing.JTable; //导入方法依赖的package包/类
/** Handle the key pressed event and change the focus if a particular
 * key combination is pressed. */
public void keyPressed(KeyEvent e) {
    if( e.isShiftDown() ) {
         int code = e.getKeyCode();
         switch(code) {
             // diagram pane
             case KeyEvent.VK_F10: 
                JTable source = (JTable)(e.getSource());

                if (DEBUG)
                    System.out.println( "QBIT : keyPressed called Shift+F10 Down source.isEnabled() returns : " + source.isEnabled() + "\n" );

                if ( ! source.isEnabled () ) return;

                // _inputTablePopupRow = source.getEditingRow();
                _inputTablePopupRow = source.getSelectedRow();
                _inputTablePopupColumn = source.getEditingColumn();
                if (_inputTablePopupColumn == (Criteria_COLUMN-1)) {
                    source.setEditingColumn(Column_COLUMN);
                }
    if (DEBUG) 
        System.out.println( "QBIT : keyPressed called\n" 
                + " inputTablePopupRow = " + _inputTablePopupRow  // NOI18N
                + " inputTablePopupColumn == Criteria_COLUMN " + (_inputTablePopupRow == Criteria_COLUMN ) // NOI18N
                + " inputTablePopupColumn = " + _inputTablePopupColumn  );  // NOI18N
            // Make sure the row where click occurred is selected.
                if (_inputTablePopupRow != -1) {
                    source.setRowSelectionInterval (_inputTablePopupRow,
                                                    _inputTablePopupRow);
                }
                _inputTablePopup.show ( source, source.getWidth() / 2, 
                                                source.getHeight() / 2 );
                break;
         }
    }
    _queryBuilder.handleKeyPress(e);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:QueryBuilderInputTable.java

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

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

示例9: updateCellRangeByTableSelection

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Uses the current table selection to update the cell range selection.
 */
void updateCellRangeByTableSelection(JTable contentTable) {
	int columnIndexStart = contentTable.getSelectedColumn();
	int rowIndexStart = contentTable.getSelectedRow();
	int columnIndexEnd = columnIndexStart + contentTable.getSelectedColumnCount() - 1;
	int rowIndexEnd = rowIndexStart + contentTable.getSelectedRowCount() - 1;
	setCellRangeSelection(new CellRangeSelection(columnIndexStart, rowIndexStart, columnIndexEnd, rowIndexEnd));
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:11,代码来源:ExcelSheetSelectionPanelModel.java

示例10: right

import javax.swing.JTable; //导入方法依赖的package包/类
public void right()
{
	TreePath path = directory.getSelectionPath();
	if( path == null )
	{
		return;
	}
	TreeNode2 tmp = (TreeNode2) path.getLastPathComponent();
	JTable table = getSelectedTable();
	int row = table.getSelectedRow();

	table.getModel().setValueAt(tmp.toString(), row, 1);

	table.updateUI();
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:LDAPMappingPanel.java

示例11: actionPerformed

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e)
{
	if( e.getSource() == left )
	{
		JTable table = getSelectedTable();
		int row = table.getSelectedRow();
		attributeModel.setValueAt("", row, 1);
		table.updateUI();
	}
	else if( e.getSource() == right )
	{
		right();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:LDAPMappingPanel.java

示例12: moverowup

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Moves the selected nullRoww one nullRoww UP., unless it the first
 * nullRoww
 *
 * @param table the target tmodel
 */
public static void moverowup(JTable table) {
    int sRow = table.getSelectedRow();
    if (sRow > 0) {
        ((DefaultTableModel) table.getModel()).moveRow(sRow, sRow, sRow - 1);
        table.getSelectionModel().setSelectionInterval(sRow - 1, sRow - 1);
    }

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:15,代码来源:JtableUtils.java

示例13: deleterow

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * get all selected rows and DELETE one by one from the last.
 *
 * @param table the table to DELETE rows
 */
public static void deleterow(JTable table) {
    int[] selectedrows = table.getSelectedRows();
    for (int row : selectedrows) {
        row = table.getSelectedRow();
        if (table.getRowSorter() != null) {
            row = table.getRowSorter().convertRowIndexToModel(row);
        }
        ((DefaultTableModel) table.getModel()).removeRow(row);
    }

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:JtableUtils.java

示例14: addrow

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Inserts new row if any row is selected else adds new row at the end
 *
 * @param table
 */
public static void addrow(JTable table) {
    int rowindex = table.getRowCount();
    if (table.getSelectedRow() > -1) {
        ((DefaultTableModel) table.getModel()).addRow(nullRow);
        ((DefaultTableModel) table.getModel()).moveRow(table.getRowCount() - 1, table.getRowCount() - 1, table.getSelectedRow());
        rowindex = table.getSelectedRow();
    } else {
        ((DefaultTableModel) table.getModel()).addRow(nullRow);
    }
    table.scrollRectToVisible(new Rectangle(table.getCellRect(rowindex, 0, true)));
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:JtableUtils.java

示例15: mousePressed

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
    Object s = e.getSource();
    if (s instanceof JTable) {
        JTable t = (JTable) s;
        int x = t.getSelectedRow();
        int y = t.getSelectedColumn();
        if (x != -1 && y != -1) {
            Object d = Objects.toString(t.getModel().getValueAt(x, y), "");
            startLocation = new Cell(x, y, d);
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:14,代码来源:TableCellDrag.java


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