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


Java JTable.getSelectedColumn方法代码示例

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


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

示例3: addcol

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Adding column is done by creating new model by modifying older one.<p>
 *
 * Insert new column if column is outside the <code>limit</code> Adds new
 * column if selected column inside the <code>limit</code>[email protected] _table
 * target table
 *
 * @param limit the range to avoid inserting
 */
static void addcol(JTable table, int limit) {
    try {
        int sc = table.getSelectedColumn();
        if (sc < limit - 1) {
            sc = table.getColumnCount() - 1;
        }

        DefaultTableModel tableM = (DefaultTableModel) table.getModel();
        DefaultTableModel tableM1 = new DefaultTableModel();
        TableModelListener[] listeners = tableM.getTableModelListeners();

        tableM1.setDataVector(newvectoraddcol(tableM.getDataVector(), sc), getColumnIdentifiersaddcol(sc + 1, table));
        table.setModel(tableM1);
        for (TableModelListener l : listeners) {
            tableM1.addTableModelListener(l);
        }

    } catch (Exception ex) {
        Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:32,代码来源:JtableUtils.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: 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

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

示例7: importData

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport support)
{
	try
	{
		Run newdata[][] = (Run[][])support.getTransferable().getTransferData(flavor);
		JTable target = (JTable)support.getComponent();
		int dr,dc;

		if (!support.isDrop())
		{
			/* Set the data */
			dr = target.getSelectedRow();
			dc = target.getSelectedColumn();

			for (int ii = 0; ii < newdata.length; ii++)
				for (int jj = 0; jj < newdata[0].length; jj++)
					target.setValueAt((newdata[ii][jj]).clone(), dr+ii, dc+jj);
		}

		return true;
	}
	catch (UnsupportedFlavorException ufe) { log.warning("Sorry, you pasted data I don't work with"); }
	catch (IOException ioe) { log.log(Level.WARNING, "I/O Error during paste:{0}", ioe.getMessage()); }
	catch (Exception e) { log.log(Level.WARNING, "General error during paste:{0}", e.getMessage()); }

	return false;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:29,代码来源:RunsTable.java

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