本文整理汇总了Java中org.jdesktop.swingx.JXList.setAutoCreateRowSorter方法的典型用法代码示例。如果您正苦于以下问题:Java JXList.setAutoCreateRowSorter方法的具体用法?Java JXList.setAutoCreateRowSorter怎么用?Java JXList.setAutoCreateRowSorter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdesktop.swingx.JXList
的用法示例。
在下文中一共展示了JXList.setAutoCreateRowSorter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initComponents
import org.jdesktop.swingx.JXList; //导入方法依赖的package包/类
private void initComponents() {
setLayout(new BorderLayout(5,5));
filterField = new JTextField();
filterField.getDocument().addDocumentListener(this);
add(filterField, BorderLayout.NORTH);
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontFamilies = env.getAvailableFontFamilyNames();
fontList = new JXList(fontFamilies);
fontList.setAutoCreateRowSorter(true);
fontList.setCellRenderer(new FontCellRenderer());
fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
fontList.addListSelectionListener(this);
fontList.setFocusable(false);
add(new JScrollPane(fontList));
}
示例2: createDemoPanel
import org.jdesktop.swingx.JXList; //导入方法依赖的package包/类
public static JPanel createDemoPanel() {
JPanel listPanel = new JPanel(new BorderLayout(5, 5));
String[] data = {"hello", "world", "world 2"};
final JXList list = new JXList(data);
list.setAutoCreateRowSorter(true);
final JTextField filterField = new JTextField(30);
final RowFilter<ListModel, Integer> filter = new RowFilter<ListModel, Integer>() {
@Override
public boolean include(RowFilter.Entry<? extends ListModel, ? extends Integer> entry) {
ListModel listModel = entry.getModel();
String value = (String) listModel.getElementAt(entry.getIdentifier());
System.out.println("value " + value);
return value.contains(filterField.getText());
/*for (int i = entry.getValueCount() - 1; i >= 0; i--) {
String value = entry.getStringValue(i);
if (value.contains(filterField.getText())) {
return true;
}
}
return false;*/
}
};
//list.setRowFilter(filter);
//list.setSortable(true);
filterField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
String text = filterField.getText();
System.out.println("Filtering with " + text);
//list.setRowFilter(RowFilter.regexFilter(text));
list.setRowFilter(filter);
}
});
listPanel.add(filterField, BorderLayout.NORTH);
listPanel.add(new JScrollPane(list));
return listPanel;
}