当前位置: 首页>>代码示例>>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;未经允许,请勿转载。