本文整理匯總了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;
}