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


Java JTable.clearSelection方法代碼示例

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


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

示例1: importData

import javax.swing.JTable; //導入方法依賴的package包/類
/**
 * Called for drop and paste operations
 */
@Override
public boolean importData(TransferHandler.TransferSupport support)
{
	try
	{
		JTable target = (JTable)support.getComponent();
		EntryModel model = (EntryModel)target.getModel();

		if (support.isDrop())
		{
			JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation();
			model.moveRow(rowsidx[0], rowsidx[rowsidx.length-1], dl.getRow());
			target.clearSelection();
		}

		return true;
	}
	catch (Exception e) { log.warning("\bGeneral error during driver drag:" + e); }

	return false;
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:25,代碼來源:DriverTable.java

示例2: setupBasicTableProperties

import javax.swing.JTable; //導入方法依賴的package包/類
/**
 * setting up the table.
 *
 * @param table JTable to store this.correlationTableModel
 */
private void setupBasicTableProperties(JTable table) {

	table.clearSelection();

	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);


	TableRenderer cellRenderer = new TableRenderer(new JTextField());

	table.setRowSelectionAllowed(true);
	table.setColumnSelectionAllowed(false);
	table.setVisible(true);
	table.setModel(this.variationPerParameterTableModel);

	initColumnSizes(table);
	for (int i = 0; i < table.getColumnCount(); i++) {
		TableColumn column = table.getColumnModel().getColumn(i);
		column.setCellRenderer(cellRenderer);
	}

	TableColumn columnName = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_NAME);
	columnName.setCellEditor(new TextCellEditor());
	TableColumn columnBasicValue = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_BASIC_VALUE);
	columnBasicValue.setCellEditor(new TextCellEditor());

   	setupVariationFunctionComboBoxColumn();

   	this.variationPerParameterTableModel.fireTableDataChanged();

	table.setColumnSelectionAllowed(false);
	table.setRowSelectionAllowed(true);

	//select first row.
	table.getSelectionModel().setSelectionInterval(0, 0);
}
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:41,代碼來源:VariationPerParameterTableController.java

示例3: marathon_select

import javax.swing.JTable; //導入方法依賴的package包/類
@Override public boolean marathon_select(String text) {
    JTable table = (JTable) component;
    boolean cellEditing = table.isEditing();
    if (cellEditing) {
        return true;
    }
    if ("".equals(text)) {
        table.clearSelection();
        return true;
    }
    int[] rows;
    int[] cols;
    if ("all".equals(text)) {
        int rowCount = table.getRowCount();
        int columnCount = table.getColumnCount();
        rows = new int[rowCount];
        cols = new int[columnCount];
        for (int i = 0; i < rowCount; i++) {
            rows[i] = i;
        }
        for (int i = 0; i < columnCount; i++) {
            cols[i] = i;
        }
    } else {
        rows = parseRows(text);
        String[] colNames = parseCols(text);
        cols = new int[colNames.length];
        for (int i = 0; i < colNames.length; i++) {
            cols[i] = getColumnIndex(colNames[i]);
        }
    }

    return selectRowsColumns(table, rows, cols);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:35,代碼來源:JTableJavaElement.java

示例4: getTableCellEditorComponent

import javax.swing.JTable; //導入方法依賴的package包/類
@Override
		public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
//			System.out.println("--1---value:"+value+",isSelected:"+isSelected+",row:"+row+",column:"+column);
			table.clearSelection();
			default_row = row;
			return panel;
		}
 
開發者ID:dev-share,項目名稱:database-transform-tool,代碼行數:8,代碼來源:ManageTable.java

示例5: getTableCellRendererComponent

import javax.swing.JTable; //導入方法依賴的package包/類
@Override
		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row, int column) {
//			System.out.println("--2---value:"+value+",isSelected:"+isSelected+",hasFocus:"+hasFocus+",row:"+row+",column:"+column);
			table.clearSelection();
			default_row = row;
			return panel;
		}
 
開發者ID:dev-share,項目名稱:database-transform-tool,代碼行數:8,代碼來源:ManageTable.java

示例6: importData

import javax.swing.JTable; //導入方法依賴的package包/類
@Override
public boolean importData(TransferHandler.TransferSupport info) {
   JTable target = (JTable) info.getComponent();
   JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation();
   int index = dl.getRow();
   int numSelected = table.getSelectedRowCount();
   int max = table.getModel().getRowCount();
   if (index + target.getSelectedRowCount() > max) return false;
   if (index < 0 || index > max)
      index = max;
   target.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
   try {		    	  
      Integer rowFrom = (Integer) info.getTransferable().getTransferData(localObjectFlavor);
      if (rowFrom != -1 && rowFrom != index) {
         ((LineSegmentsObject)table.getModel()).reorder(rowFrom, index, numSelected);
      }
      //update the selected rows
      target.clearSelection();
      int index1 = index + numSelected - 1;
      target.addRowSelectionInterval(index, index1);

      return true; 
   } catch (Exception e) {
      e.printStackTrace();
   }
   return false;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:28,代碼來源:Digitizer.java

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