本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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)
{ }
}
}
}
示例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;
}
示例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;
}