本文整理匯總了Java中javax.swing.table.JTableHeader.columnAtPoint方法的典型用法代碼示例。如果您正苦於以下問題:Java JTableHeader.columnAtPoint方法的具體用法?Java JTableHeader.columnAtPoint怎麽用?Java JTableHeader.columnAtPoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.table.JTableHeader
的用法示例。
在下文中一共展示了JTableHeader.columnAtPoint方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mouseClicked
import javax.swing.table.JTableHeader; //導入方法依賴的package包/類
public void mouseClicked(MouseEvent e) {
JTableHeader h = (JTableHeader) e.getSource();
TableColumnModel columnModel = h.getColumnModel();
int viewColumn = h.columnAtPoint(e.getPoint());
int column = columnModel.getColumn(viewColumn).getModelIndex();
if (column != -1) {
int status = getSortingStatus(column);
if (!e.isControlDown()) {
cancelSorting();
}
// Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
// {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
status = status + (e.isShiftDown() ? -1
: 1);
status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
setSortingStatus(column, status);
}
}
示例2: mouseClicked
import javax.swing.table.JTableHeader; //導入方法依賴的package包/類
public void mouseClicked (MouseEvent evt) {
Component c = evt.getComponent ();
if (c instanceof JTableHeader) {
JTableHeader h = (JTableHeader)c;
// show/hide additional properties
if (1 == h.columnAtPoint (evt.getPoint ())) {
refreshColumns (true);
}
}
}