当前位置: 首页>>代码示例>>Java>>正文


Java RowSorter.getSortKeys方法代码示例

本文整理汇总了Java中javax.swing.RowSorter.getSortKeys方法的典型用法代码示例。如果您正苦于以下问题:Java RowSorter.getSortKeys方法的具体用法?Java RowSorter.getSortKeys怎么用?Java RowSorter.getSortKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.RowSorter的用法示例。


在下文中一共展示了RowSorter.getSortKeys方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSortKey

import javax.swing.RowSorter; //导入方法依赖的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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:21,代码来源:TableHeaderUI.java

示例2: getSortKey

import javax.swing.RowSorter; //导入方法依赖的package包/类
/**
 * Returns the current sort key, or null if the column is unsorted.
 *
 * @param table the table
 * @param column the column index
 * @return the SortKey, or null if the column is unsorted
 */
@SuppressWarnings("rawtypes")
protected SortKey getSortKey(JTable table, int column) {
    RowSorter rowSorter = table.getRowSorter();
    if (rowSorter == null) {
        return null;
    }

    List sortedColumns = rowSorter.getSortKeys();
    if (!sortedColumns.isEmpty()) {
        return (SortKey) sortedColumns.get(0);
    }
    return null;
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:21,代码来源:DefaultTableHeaderCellRenderer.java

示例3: getSortKey

import javax.swing.RowSorter; //导入方法依赖的package包/类
/**
 * Returns the current sort key, or null if the column is unsorted.
 *
 * @param table the table
 * @param column the column index
 * @return the SortKey, or null if the column is unsorted
 */
protected SortKey getSortKey(JTable table, int column) {
  RowSorter rowSorter = table.getRowSorter();
  if (rowSorter == null) {
    return null;
  }

  List sortedColumns = rowSorter.getSortKeys();
  if (sortedColumns.size() > 0) {
    return (SortKey) sortedColumns.get(0);
  }
  return null;
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:20,代码来源:DefaultTableHeaderCellRenderer.java

示例4: getSortKey

import javax.swing.RowSorter; //导入方法依赖的package包/类
/**
 * Returns the current sort key, or null if the column is unsorted.
 *
 * @param table the table
 * @param column the column index
 * @return the SortKey, or null if the column is unsorted
 */
protected SortKey getSortKey(JTable table, int column) {
    RowSorter rowSorter = table.getRowSorter();
    if (rowSorter == null) {
        return null;
    }

    List sortedColumns = rowSorter.getSortKeys();
    if (sortedColumns.size() > 0) {
        return (SortKey) sortedColumns.get(0);
    }
    return null;
}
 
开发者ID:chatty,项目名称:chatty,代码行数:20,代码来源:ExtendableDefaultTableHeaderCellRenderer.java

示例5: getSortKey

import javax.swing.RowSorter; //导入方法依赖的package包/类
protected RowSorter.SortKey getSortKey(JTable table, int column) {
	RowSorter<? extends TableModel> rowSorter = table.getRowSorter();
	if (rowSorter == null) {
		return null;
	}
	List<? extends RowSorter.SortKey> sortedColumns = rowSorter
			.getSortKeys();
	return sortedColumns.isEmpty() ? null : sortedColumns.get(0);
}
 
开发者ID:pfichtner,项目名称:jrunalyzer,代码行数:10,代码来源:TableHeaderRenderer.java

示例6: MyRenderComponent

import javax.swing.RowSorter; //导入方法依赖的package包/类
public MyRenderComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    super();
    this.table = table;
    this.col = col;
    if (value != null) {
        setText(value.toString());
    } else {
        setText("");
    }
    setOpaque(false);
    setForeground(UIManager.getColor("TableHeader.foreground"));
    setHorizontalAlignment(JLabel.CENTER);
    setHorizontalTextPosition(SwingConstants.LEADING);
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    if (JTattooUtilities.getJavaVersion() >= 1.6) {
        RowSorter rowSorter = table == null ? null : table.getRowSorter();
        List keyList = rowSorter == null ? null : rowSorter.getSortKeys();
        if ((keyList != null) && (keyList.size() > 0)) {
            RowSorter.SortKey sortKey = (RowSorter.SortKey) keyList.get(0);
            if (sortKey.getColumn() == table.convertColumnIndexToModel(col)) {
                AbstractIconFactory iconFactory = ((AbstractLookAndFeel) UIManager.getLookAndFeel()).getIconFactory();
                if (sortKey.getSortOrder().equals(SortOrder.ASCENDING)) {
                    setIcon(iconFactory.getUpArrowIcon());
                } else if (sortKey.getSortOrder().equals(SortOrder.DESCENDING)) {
                    setIcon(iconFactory.getDownArrowIcon());
                }
            }
        }
    }
    gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getTheme().getRolloverColor());
}
 
开发者ID:MegaDiablo,项目名称:android-packages-manager,代码行数:32,代码来源:BaseTableHeaderUI.java

示例7: storeTable

import javax.swing.RowSorter; //导入方法依赖的package包/类
public void storeTable(String prefix, JTable t, boolean storeSelection)
{
	if(t.getColumnCount() > 0)
	{
		SB sb = new SB();

		RowSorter<?> sorter = t.getRowSorter();
		if(sorter != null)
		{
			List<? extends RowSorter.SortKey> keys = sorter.getSortKeys();
			if(keys != null)
			{
				for(RowSorter.SortKey k: keys)
				{
					switch(k.getSortOrder())
					{
					case ASCENDING: 
						sb.append(SORT_ASCENDING);
						sb.append(',');
						break;
					case DESCENDING:
						sb.append(SORT_DESCENDING);
						sb.append(',');
						break;
					default:
						sb.append(SORT_NONE);
						sb.append(',');
						break;
					}
					sb.append(k.getColumn());
					sb.append(',');
				}
				sb.append(-1);
				
				set(prefix + TABLE_SORT, sb);
				sb.setLength(0);
			}
		}
		
		Enumeration<TableColumn> en = t.getColumnModel().getColumns();
		while(en.hasMoreElements())
		{
			TableColumn col = en.nextElement();
			// width
			sb.append(col.getWidth());
			sb.append(',');
			// model index
			sb.append(col.getModelIndex());
			sb.append(',');
		}
		sb.append("-1");
		
		String s = sb.toString();
		set(prefix + TABLE, s);
	}
	
	if(storeSelection)
	{
		int ix = t.getSelectedRow();
		if(ix >= 0)
		{
			try
			{
				ix = t.convertRowIndexToModel(ix);
				set(prefix + TABLE_SELECTION, ix);
			}
			catch(Exception e)
			{ }
		}
	}
}
 
开发者ID:andy-goryachev,项目名称:PasswordSafe,代码行数:72,代码来源:UISettings.java

示例8: getTableCellRendererComponent

import javax.swing.RowSorter; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value,
                 boolean isSelected, boolean hasFocus, int row, int column) {
  setFont(table.getFont());
  String str = (value == null) ? "" : value.toString();
  BufferedReader br = new BufferedReader(new StringReader(str));
  String line;
  Vector v = new Vector();
  try {
    while ((line = br.readLine()) != null) {
      v.addElement(line);
    }
  } catch (IOException ex) {
    ex.printStackTrace();
  }
  dataList.setListData(v);

  Icon icon;
  //Check if needs sorting
  boolean isSorted = false;
  if (table.getRowSorter() != null) {
      RowSorter sorter = table.getRowSorter();
      List sortKeys = sorter.getSortKeys();
      Iterator sortIterator = sortKeys.iterator();
      if (sortIterator.hasNext()) {
          RowSorter.SortKey key = (RowSorter.SortKey) sortIterator.next();
          if (key.getColumn() == column) {
              switch (key.getSortOrder()) {
                  case ASCENDING:
                      icon = JHeaderSorterIcons.ASC.getIcon();
                      iconLabel.setIcon(icon);
                      isSorted = true;
                      break;
                  case DESCENDING:
                      icon = JHeaderSorterIcons.DESC.getIcon();
                      iconLabel.setIcon(icon);
                      isSorted = true;
                      break;
                  default:
                      break;
              }
          }
      }
  }
  if (!isSorted) iconLabel.setIcon(null);


  return this;
  
  
}
 
开发者ID:genomeartist,项目名称:genomeartist,代码行数:51,代码来源:MultilineHeaderRenderer.java

示例9: getTableCellRendererComponent

import javax.swing.RowSorter; //导入方法依赖的package包/类
/**
 * @see com.seaglasslookandfeel.ui.SeaGlassTableHeaderUI$DefaultTableCellHeaderRenderer#getTableCellRendererComponent(javax.swing.JTable,
 *      java.lang.Object, boolean, boolean, int, int)
 */
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
        int column) {
    boolean hasRollover = false; // (column == getRolloverColumn());

    if (isSelected || hasRollover || hasFocus) {
        SeaGlassLookAndFeel.setSelectedUI((SeaGlassLabelUI) SeaGlassLookAndFeel.getUIOfType(getUI(), SeaGlassLabelUI.class),
                                          isSelected, hasFocus, table.isEnabled(), hasRollover);
    } else {
        SeaGlassLookAndFeel.resetSelectedUI();
    }

    // Stuff a variable into the client property of this renderer
    // indicating the sort order, so that different rendering can be
    // done for the header based on sorted state.
    RowSorter                                   rs       = table == null ? null : table.getRowSorter();
    java.util.List<? extends RowSorter.SortKey> sortKeys = rs == null ? null : rs.getSortKeys();

    if (sortKeys != null && sortKeys.size() > 0 && sortKeys.get(0).getColumn() == table.convertColumnIndexToModel(column)) {
        switch (sortKeys.get(0).getSortOrder()) {

        case ASCENDING:
            putClientProperty("Table.sortOrder", "ASCENDING");
            break;

        case DESCENDING:
            putClientProperty("Table.sortOrder", "DESCENDING");
            break;

        case UNSORTED:
            putClientProperty("Table.sortOrder", "UNSORTED");
            break;

        default:
            throw new AssertionError("Cannot happen");
        }
    } else {
        putClientProperty("Table.sortOrder", "UNSORTED");
    }

    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

    return this;
}
 
开发者ID:khuxtable,项目名称:seaglass,代码行数:49,代码来源:SeaGlassTableHeaderUI.java


注:本文中的javax.swing.RowSorter.getSortKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。