本文整理汇总了Java中javax.swing.RowSorter.SortKey.getColumn方法的典型用法代码示例。如果您正苦于以下问题:Java SortKey.getColumn方法的具体用法?Java SortKey.getColumn怎么用?Java SortKey.getColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.RowSorter.SortKey
的用法示例。
在下文中一共展示了SortKey.getColumn方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSortedColumn
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
/**
* Returns the primary sort column, or null if nothing sorted or no sortKey
* corresponds to a TableColumn currently contained in the TableColumnModel.
*
* @return the currently interactively sorted TableColumn or null if there
* is not sorter active or if the sorted column index does not
* correspond to any column in the TableColumnModel.
*/
public TableColumn getSortedColumn() {
// bloody hack: get primary SortKey and
// check if there's a column with it available
RowSorter<?> controller = getRowSorter();
if (controller != null) {
// PENDING JW: must use RowSorter?
SortKey sortKey = SortUtils.getFirstSortingKey(controller
.getSortKeys());
if (sortKey != null) {
int sorterColumn = sortKey.getColumn();
List<TableColumn> columns = getColumns(true);
for (Iterator<TableColumn> iter = columns.iterator(); iter
.hasNext();) {
TableColumn column = iter.next();
if (column.getModelIndex() == sorterColumn) {
return column;
}
}
}
}
return null;
}
示例2: getTableCellRendererComponent
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setBackground(Constants.DS_BACK);
DefaultTableCellRenderer r = ((DefaultTableCellRenderer) c);
r.setText("<html><b>" + r.getText() + "</b></html>");
try {
List<? extends SortKey> sortKeys = table.getRowSorter().getSortKeys();
SortKey key = sortKeys.get(0);
if (column == key.getColumn()) {
r.setIcon(key.getSortOrder() == SortOrder.ASCENDING ? ascIcon : descIcon);
} else {
r.setIcon(null);
}
} catch (Exception e) {
r.setIcon(null);
}
return r;
}
示例3: setSortKeys
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
public final void setSortKeys(final List<? extends SortKey> sortKeys)
{
sortIndexes2Direction.clear();
if (sortKeys == null || sortKeys.isEmpty())
{
return;
}
for (final SortKey sortKey : sortKeys)
{
final int modelColumnIndex = sortKey.getColumn();
final Boolean isSortAscending = getSortAscendingFlagOfSortOrder(sortKey.getSortOrder());
if (isSortAscending == null)
{
continue;
}
sortIndexes2Direction.put(modelColumnIndex, isSortAscending);
}
}
示例4: sorterChanged
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
@Override
public void sorterChanged(RowSorterEvent e) {
if (e.getType() == Type.SORT_ORDER_CHANGED) {
@SuppressWarnings("unchecked")
List<? extends SortKey> sortKeys = e.getSource().getSortKeys();
Object[] keys = new Object[sortKeys.size()];
boolean[] directions = new boolean[sortKeys.size()];
int index = 0;
for (SortKey s : sortKeys) {
keys[index] = SwingTable.this.keys[s.getColumn()];
directions[index] = s.getSortOrder() == SortOrder.ASCENDING;
index++;
}
if (list instanceof Sortable) {
((Sortable) list).sort(keys, directions);
}
setOffset(0);
}
}
示例5: isSameSorter
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
private boolean isSameSorter(List<? extends SortKey> sortKeys1,
List<? extends SortKey> sortKeys2) {
int size1 = (sortKeys1 == null) ? 0 : sortKeys1.size();
int size2 = (sortKeys2 == null) ? 0 : sortKeys2.size();
if ((size1 == 0) && (size2 == 0)) {
return true;
}
if ((sortKeys1 == null) && (sortKeys2 == null))
return true;
if ((sortKeys1 == null) || (sortKeys2 == null))
return false;
if (size1 != size2)
return false;
for (int i = 0; i < size1; i++) {
SortKey sortKey1 = sortKeys1.get(i);
SortKey sortKey2 = sortKeys2.get(i);
if ((sortKey1.getColumn() != sortKey2.getColumn())
|| (sortKey1.getSortOrder() != sortKey2.getSortOrder())) {
return false;
}
}
return true;
}
示例6: valueChanged
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void valueChanged(final ListSelectionEvent e) {
// fix for issue 478 - no animations when sorter has changed
List<? extends SortKey> sortKeys = (table.getRowSorter() == null) ? null
: table.getRowSorter().getSortKeys();
boolean isDifferentSorter = !isSameSorter(sortKeys, oldSortKeys);
if (e.getValueIsAdjusting() && isDifferentSorter)
return;
if (sortKeys == null) {
oldSortKeys = null;
} else {
oldSortKeys = new ArrayList<SortKey>();
for (SortKey sortKey : sortKeys) {
SortKey copy = new SortKey(sortKey.getColumn(),
sortKey.getSortOrder());
oldSortKeys.add(copy);
}
}
syncSelection(isDifferentSorter);
}
示例7: getSortKey
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
/**
* Tries to return the sort key for the given column.
*
* @param sorter
* @param column
* @return the sort key or {@code null}
*/
private SortKey getSortKey(RowSorter<? extends TableModel> sorter, int column) {
if (sorter == null) {
return null;
}
for (Object sortObj : sorter.getSortKeys()) {
SortKey key = (SortKey) sortObj;
if (key.getColumn() == column) {
return key;
}
}
return null;
}
示例8: rowSorterChanged
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
private void
rowSorterChanged() {
List<? extends SortKey> list = getRowSorter().getSortKeys();
if(list.isEmpty()) return;
SortKey k = list.get(0);
int i = k.getColumn() + 1;
if(k.getSortOrder() == SortOrder.UNSORTED) return;
if(k.getSortOrder() == SortOrder.DESCENDING) i *= -1;
preferences().setIntProperty(tablePrefix + "sortOrder", i);
}
示例9: isSortingCriteria
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
public boolean isSortingCriteria(int column) {
checkColumn(column);
for (int i = 0; i < criteria.size(); i++) {
SortKey key = criteria.get(i);
if (key.getColumn() == column) {
return true;
}
}
return false;
}
示例10: getTableCellRendererComponent
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel comp = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
comp.setBackground(myBgColor);
comp.setHorizontalAlignment(JLabel.CENTER);
if (tooltip == null) {
comp.setToolTipText(GuiMessages.getString(value.toString()));
}
else {
comp.setToolTipText("<HTML>"+tooltip+"</HTML>");
}
comp.setIcon(null);
/*
if (dbTable != null) {
Vector<Integer> v = dbTable.getSortColumns();
if (v != null && v.size() > 0 && v.get(0) == column + 1) {
comp.setIcon(dbTable.isSortAscending() ? ascIcon : descIcon);
comp.repaint();
}
}
*/
if (table != null && table.getRowSorter() != null) { // && myBgColor != dbTable.getTable().getTableHeader().getBackground()
if (table.getRowSorter().getSortKeys().size() > 0) {
SortKey sk = table.getRowSorter().getSortKeys().get(0);
int sortCol = sk.getColumn();
//System.out.println(comp + "\tgetSortColumns\t" + sortCol);
if (column + 1 == sortCol) {
sk.getSortOrder();
comp.setIcon(sk.getSortOrder() == SortOrder.ASCENDING ? ascIcon : descIcon);
}
}
}
//comp.setText("W");
comp.setText(GuiMessages.getString(comp.getText()));
return comp;
}
示例11: SortKeyState
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
/**
* Constructor used by property.
*
* @param sortKey
*/
public SortKeyState(SortKey sortKey) {
this(SortUtils.isAscending(sortKey.getSortOrder()), sortKey.getColumn());
}