⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ktablesortonclick.java

📁 ktable 是一个由java开发的,对控制报表的项目,它最大的特点是使用独特的算法,能支持巨大的报表(千万以上?).
💻 JAVA
字号:
package de.kupzog.ktable;


/**
 * This class provides the code that makes the table sort when the user
 * clicks on the table header.
 * 
 */
public class KTableSortOnClick extends KTableCellSelectionAdapter {

	KTable m_Table;
	KTableSortComparator m_SortComparator; 
	
	
	public KTableSortOnClick(KTable table, KTableSortComparator comparator) {
		m_Table = table;
		m_SortComparator = comparator;
	}

	/**
	 * Implements sorting behavior when clicking on the fixed header row.
	 */
	public void fixedCellSelected(int col, int row, int statemask) {
		if (m_Table.getModel() instanceof KTableSortedModel) {
			KTableSortedModel model = (KTableSortedModel) m_Table.getModel();
			
			// implement the sorting when clicking on the header.
			if (row<model.getFixedHeaderRowCount() && 
					col>=model.getFixedHeaderColumnCount()) {
				int type = KTableSortComparator.SORT_UP;
				if (model.getSortColumn()==col) {
					if (model.getSortState()==KTableSortComparator.SORT_UP) {
						type = KTableSortComparator.SORT_DOWN;
					} else if (model.getSortState()==KTableSortComparator.SORT_DOWN) {
						type = KTableSortComparator.SORT_NONE;
					}
				}
				
				// update the comparator properly: 
				m_SortComparator.setColumnToCompare(col);
				m_SortComparator.setSortDirection(type);
				
				// perform the sorting
				model.sort(m_SortComparator);
				
				// needed to make the resorting visible!
				m_Table.redraw(); 
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -