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


Java DefaultTableModel.getColumnCount方法代碼示例

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


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

示例1: addColumn

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
public TableColumn addColumn(Object columnIdentifier, int width,
                             TableCellRenderer renderer,
                             TableCellEditor editor, List columnData) {
    checkDefaultTableModel();

    // Set up the model side first
    DefaultTableModel m = (DefaultTableModel)getModel();
    m.addColumn(columnIdentifier, columnData.toArray());

    // The column will have been added to the end, so the index of the
    // column in the model is the last element.
    TableColumn newColumn = new TableColumn(
            m.getColumnCount()-1, width, renderer, editor);
    super.addColumn(newColumn);
    return newColumn;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:OldJTable.java

示例2: init

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void init()
{
	model = new DefaultTableModel()
	{
		private static final long serialVersionUID = 1L;

		@Override
		public Class<?> getColumnClass(int c)
		{
			Object value = getValueAt(0, c);
			Class<?> cs = null;
			if( value != null )
			{
				cs = value.getClass();
			}
			else
			{
				cs = super.getColumnClass(c);
			}
			return cs;
		}
	};
	model.setColumnIdentifiers(getColumnNames());
	table = new JTable(model);
	table.getSelectionModel().addListSelectionListener(this);
	table.setRowHeight(20);

	int count = model.getColumnCount();
	for( int i = 0; i < count; i++ )
	{
		TableColumn column = table.getColumnModel().getColumn(i);
		processTableColumn(column, i);
	}
	table.doLayout();

	this.setLayout(new BorderLayout());
	this.add(new JScrollPane(table), BorderLayout.CENTER);
	this.add(createBottom(), BorderLayout.SOUTH);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:40,代碼來源:AbstractTableMapping.java

示例3: updateResultSetDataFromTableModel

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
public void updateResultSetDataFromTableModel(DefaultTableModel aTableModel) {
	resultSetData = new Vector(aTableModel.getDataVector());
	resultSetColumns = new Vector<String>();
	// Get columns names
	for (int i = 0; i < aTableModel.getColumnCount(); i++) {
		resultSetColumns.add(aTableModel.getColumnName(i));
	}
}
 
開發者ID:tteguayco,項目名稱:JITRAX,代碼行數:9,代碼來源:Query.java

示例4: refreshTableModel

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
	 * Refreshes the local table model by reloading the data from the DynForm.
	 */
	@SuppressWarnings("unchecked")
	public void refreshTableModel() {
		
		int rowIndexSelected = this.getSelectedRow();
		
		DefaultTableModel dtm = (DefaultTableModel) this.getModel();
		if (dtm.getColumnCount()==0) {
			// --- Create a new table model ---------------
			Vector<String> columnNames = new Vector<String>();
			columnNames.add(" ");
			columnNames.add(" ");
			
			dtm = this.getTableModel();
			dtm.setDataVector(this.getDataVector(), columnNames);
			this.setModel(dtm);
			this.setRendererAndEditors();
			this.setRowSorter(this.getMyRowSorter());
			
		} else {
			// --- Exchange or re-new the data model ------
			DynTableDataVector newDataVector = new DynTableDataVector(this.dynForm);
			if (newDataVector.isEqualStructure(dtm.getDataVector())==false) {
				// --- exchange data completely -----------
				this.setDataVector(newDataVector);
				dtm.getDataVector().removeAllElements();
				dtm.getDataVector().addAll(this.getDataVector());
				dtm.fireTableDataChanged();
				this.setRowSorter(this.getMyRowSorter());
				
			} else {
				// --- Same structure! -------------------- 
				// --- => Just exchange different values --
				
// 				// --- THIS IS JUST A BACKUP SOLUTION ----- 				
//				for (int i=0; i < this.getDataVector().size(); i++) {
//					
//					Object objectThisRow = this.getDataVector().get(i);
//					Vector<Object> rowThis = (Vector<Object>) objectThisRow;
//					DynType dynTypeThis = (DynType) rowThis.get(0);
//					JComponent jCompThis = dynTypeThis.getFieldDisplay();
//					
//					Object objectNewRow = newDataVector.get(i);
//					Vector<Object> rowNew = (Vector<Object>) objectNewRow;
//					DynType dynTypeNew = (DynType) rowNew.get(0);
//					JComponent jCompNew = dynTypeNew.getFieldDisplay();
//					
//					if ((jCompThis!=null && jCompNew!=null) && jCompThis.getClass().getName().equals(jCompNew.getClass().getName())==true) {
//						if (jCompThis instanceof JTextField) {
//							((JTextField) jCompThis).setText(((JTextField) jCompNew).getText());
//						} else if (jCompThis instanceof JCheckBox) {
//							((JCheckBox) jCompThis).setSelected(((JCheckBox) jCompNew).isSelected());
//						}
//					}
//					
//				}
				dtm.fireTableDataChanged();
				
			}
			
		}
		
		// --- Set new selection --------------------------
		int rowCount = this.getRowCount();
		if (rowIndexSelected>(rowCount-1)) {
			this.setRowSelectionInterval(rowCount-1, rowCount-1);
		} else if (rowIndexSelected>-1) {
			this.setRowSelectionInterval(rowIndexSelected, rowIndexSelected);
		}
	}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:73,代碼來源:DynTable.java

示例5: refreshTableau

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
public void refreshTableau() {
	DefaultTableModel mod = this.panneauCalendrier.model;
	
	//Retrait des rows
	for(int i = 0; i < mod.getRowCount(); i++) {
		mod.removeRow(i);
	}
	
	//Ajout des lignes
	for(Lot l : this.getProject().getLotList()) {
		String[] row = new String[mod.getColumnCount()];
		row[0] = l.getName();
		SimpleDateFormat sdf = new SimpleDateFormat("dd-yyyy");
		Date ddebut = l.getStartDate();
		Date dfin 	= l.getEndDate();
		
		for(int i = 1; i < mod.getColumnCount(); i++) {
			try {
				String[] ddyyl = mod.getColumnName(i).split(" ");
				String ddyy = ddyyl[1] + "-" + ddyyl[2];
				
				
				Date date = sdf.parse(ddyy);
				if(date.getTime() >= ddebut.getTime() - (86400000) && date.getTime() <= dfin.getTime()) {
					row[i] = "X";
				} else {
					row[i] = " ";
				}
			} catch(Exception ex) {
				ex.printStackTrace();
				row[i] = " _ ";
			}
			
		}
		
		mod.addRow(row);
	}
	
	this.panneauCalendrier.model.fireTableDataChanged();
	this.pack();
	this.validate();
}
 
開發者ID:TeamLDCCIIT,項目名稱:Java_GestionProjet,代碼行數:43,代碼來源:FenetreGestionDeProjet.java


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