本文整理汇总了Java中org.jdesktop.swingx.JXList类的典型用法代码示例。如果您正苦于以下问题:Java JXList类的具体用法?Java JXList怎么用?Java JXList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JXList类属于org.jdesktop.swingx包,在下文中一共展示了JXList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installUI
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* Initializes <code>this.list</code> by calling <code>installDefaults()</code>,
* <code>installListeners()</code>, and <code>installKeyboardActions()</code>
* in order.
*
* @see #installDefaults
* @see #installListeners
* @see #installKeyboardActions
*/
public void installUI(JComponent c)
{
list = (JXList)c;
layoutOrientation = list.getLayoutOrientation();
rendererPane = new CellRendererPane();
list.add(rendererPane);
columnCount = 1;
updateLayoutStateNeeded = modelChanged;
isLeftToRight = list.getComponentOrientation().isLeftToRight();
installDefaults();
installListeners();
installKeyboardActions();
installSortUI();
}
示例2: interactiveIconTextAlignmentAndExtendsOpacity
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* Requirement: left aligned icon and right aligned text.
* http://forums.java.net/jive/thread.jspa?messageID=398448#398448
*
* Issue #1309-swingx: WrappingProvider needs option to "highlight" the icon as well.
*/
public void interactiveIconTextAlignmentAndExtendsOpacity() {
ListModel files = createFileListModel();
final JXList list = new JXList(files);
ComponentProvider<?> text = new LabelProvider(StringValues.FILE_NAME, JLabel.TRAILING);
final WrappingProvider wrapper = new WrappingProvider(IconValues.FILE_ICON, text, true);
wrapper.setExtendsComponentOpacity(true);
list.setCellRenderer(new DefaultListRenderer(wrapper));
list.addHighlighter(HighlighterFactory.createSimpleStriping());
JXFrame frame =showWithScrollingInFrame(list, "alignment in wrappingProvider");
Action action = new AbstractAction("toggle icon opacity") {
@Override
public void actionPerformed(ActionEvent e) {
wrapper.setExtendsComponentOpacity(!wrapper.getExtendsComponentOpacity());
list.repaint();
}
};
addAction(frame, action);
JLabel label = new JLabel(IconValues.FILE_ICON.getIcon(list.getElementAt(1)));
addStatusComponent(frame, label);
}
示例3: interactiveDropOnVisualsList
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* Issue #370-swingx: drop-on not shown correctly.
*
* Check core default renderer as renderer in Table.
*/
public void interactiveDropOnVisualsList() {
JXList xTable = new JXList(AncientSwingTeam.createNamedColorListModel());
installTransferHandler(xTable);
JList table = new JList(xTable.getModel());
installTransferHandler(table);
// xTable.setDropMode(DropMode.USE_SELECTION);
// table.setDropMode(DropMode.USE_SELECTION);
xTable.setDropMode(DropMode.ON_OR_INSERT);
table.setDropMode(DropMode.ON_OR_INSERT);
JXFrame frame = wrapWithScrollingInFrame(xTable, table,
"JXList <-> core list: drop-on appearance");
JTextField textField = new JTextField("drag me over first column....");
textField.setDragEnabled(true);
addStatusComponent(frame, textField);
show(frame);
}
示例4: interactiveIconPainterHighlight
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* Use highlighter with background image painter. Shared by table and list.
*/
public void interactiveIconPainterHighlight() throws Exception {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
ComponentProvider<JLabel> controller = new LabelProvider(
JLabel.RIGHT);
table.getColumn(0).setCellRenderer(
new DefaultTableRenderer(controller));
final ImagePainter imagePainter = new ImagePainter(XTestUtils.loadDefaultImage());
HighlightPredicate predicate = new ColumnHighlightPredicate(0);
Highlighter iconHighlighter = new PainterHighlighter(predicate, imagePainter );
Highlighter alternateRowHighlighter = HighlighterFactory.createSimpleStriping();
table.addHighlighter(alternateRowHighlighter);
table.addHighlighter(iconHighlighter);
// re-use component controller and highlighter in a JXList
JXList list = new JXList(createListNumberModel(), true);
list.setCellRenderer(new DefaultListRenderer(controller));
list.addHighlighter(alternateRowHighlighter);
list.addHighlighter(iconHighlighter);
list.toggleSortOrder();
final JXFrame frame = showWithScrollingInFrame(table, list,
"image highlighting plus striping");
frame.pack();
}
示例5: interactiveValueBasedRelativePainterHighlight
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* Use highlighter with image painter which is positioned relative to
* cell value.
*/
public void interactiveValueBasedRelativePainterHighlight() {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
final ImagePainter imagePainter = new ImagePainter(XTestUtils.loadDefaultImage("green-orb.png"));
imagePainter.setHorizontalAlignment(HorizontalAlignment.RIGHT);
imagePainter.setAreaEffects(new InnerGlowPathEffect());
RelativePainterHighlighter iconHighlighter = new RelativePainterHighlighter(imagePainter);
iconHighlighter.setHorizontalAlignment(HorizontalAlignment.LEFT);
iconHighlighter.setRelativizer(new NumberRelativizer(100));
table.getColumnExt(3).addHighlighter(iconHighlighter);
// re-use component controller and highlighter in a JXList
JXList list = new JXList(createListNumberModel(), true);
list.setCellRenderer(new DefaultListRenderer(new LabelProvider(JLabel.RIGHT)));
list.addHighlighter(iconHighlighter);
list.setComparator(DefaultSortController.COMPARABLE_COMPARATOR);
list.toggleSortOrder();
showWithScrollingInFrame(table, list,
"value-based image position (with relativePainterHighlighter)");
}
示例6: interactiveValueBasedGradientHighlightPlusStriping
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* Use transparent gradient painter for value-based background highlighting
* with SwingX extended default renderer. Shared by table and list with
* striping.
*/
public void interactiveValueBasedGradientHighlightPlusStriping() {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
ComponentProvider<JLabel> controller = new LabelProvider(
JLabel.RIGHT) ;
RelativePainterHighlighter gradientHighlighter =
createRelativeGradientHighlighter(HorizontalAlignment.RIGHT, 100);
table.addHighlighter(gradientHighlighter);
Highlighter alternateRowHighlighter = HighlighterFactory.createSimpleStriping();
table.addHighlighter(alternateRowHighlighter);
table.addHighlighter(gradientHighlighter);
// re-use component controller and highlighter in a JXList
JXList list = new JXList(createListNumberModel(), true);
list.setCellRenderer(new DefaultListRenderer(controller));
list.addHighlighter(alternateRowHighlighter);
list.addHighlighter(gradientHighlighter);
list.toggleSortOrder();
final JXFrame frame = wrapWithScrollingInFrame(table, list,
"transparent value relative highlighting plus striping");
addStatusMessage(frame,
"uses a PainterAwareLabel in renderer");
// crude binding to play with options - the factory is incomplete...
// addStatusComponent(frame, createTransparencyToggle(gradientHighlighter));
// show(frame);
}
示例7: interactiveListRollover
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
public void interactiveListRollover() {
final JXList table = new JXList(listModel);
table.setRolloverEnabled(true);
final CompoundHighlighter compoundHighlighter = new CompoundHighlighter(foregroundHighlighter);
table.setHighlighters(compoundHighlighter);
JXFrame frame = wrapWithScrollingInFrame(table, "List with rollover");
Action toggleAction = new AbstractAction("toggle foreground/background") {
boolean isBackground;
public void actionPerformed(ActionEvent e) {
if (isBackground) {
compoundHighlighter.addHighlighter(foregroundHighlighter);
compoundHighlighter.removeHighlighter(backgroundHighlighter);
} else {
compoundHighlighter.addHighlighter(backgroundHighlighter);
compoundHighlighter.removeHighlighter(foregroundHighlighter);
}
isBackground = !isBackground;
}
};
addAction(frame, toggleAction);
frame.setVisible(true);
}
示例8: interactiveRolloverDisabledClickList
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* Issue #1374-swingx: Rollover click must be disabled if target disabled
*
* Visual test for JXTable, adapted from reporter's test case
*/
public void interactiveRolloverDisabledClickList() {
JXList table = new JXList(AncientSwingTeam.createNamedColorListModel());
table.setEnabled(false);
table.setRolloverEnabled(true);
final JXFrame frame = showWithScrollingInFrame(table, "disable list must not trigger rollover renderer");
// rollover-enabled default renderer
DefaultListRenderer renderer = new DefaultListRenderer() {
@Override
public void doClick() {
JOptionPane.showMessageDialog(frame, "Click");
}
@Override
public boolean isEnabled() {
return true;
}
};
table.setCellRenderer(renderer);
addEnabledToggle(frame, table);
}
示例9: testSelectionWithFilterXListRemove
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* Issue #1536-swingx: AIOOB on restoring selection with filter
* Reopened: overfixed - the removeIndexInterval _does_ take
* the endIndex instead of length.
*
*/
@Test
public void testSelectionWithFilterXListRemove() {
JXList table = new JXList(ascendingListModel, true);
// set selection somewhere below the filtered (which is 0)
int selected = 1;
table.setSelectionInterval(selected, selected);
// exclude rows based on identifier (here: first item
final RowFilter filter = new RowFilters.GeneralFilter() {
List excludes = Arrays.asList(0);
@Override
protected boolean include(
Entry<? extends Object, ? extends Object> entry,
int index) {
return !excludes.contains(entry.getIdentifier());
}
};
table.setRowFilter(filter);
assertEquals("sanity: filtered selection", selected - 1, table.getSelectedIndex());
// remove last row
ascendingListModel.remove(ascendingListModel.getSize() - 1);
assertEquals("filtered selection unchanged", selected - 1, table.getSelectedIndex());
assertFalse(table.isSelectionEmpty());
}
示例10: testSynthXUIFound
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* For SynthLF, mapping of ui-delegate happens statically in Region: for all
* known regions it registers the SynthLookAndFeel as delegate factory. First
* time around, Region.XLIST is not yet known - xdelegate used. Second time
* around, the new region is known, factory replaced with SynthLF which can't
* handle ... so need to hide XLIST from registration.<p>
*
* PENDING JW: not entirely sure as to the why, could be special to our
* addon mechanism?
*
* @throws Exception
*/
@Test
public void testSynthXUIFound() throws Exception {
if (!hasLookAndFeel("Nimbus")) {
LOG.info("can't run - no Nimbus");
return;
}
LookAndFeel lf = UIManager.getLookAndFeel();
try {
setLookAndFeel("Nimbus");
JXList list = new JXList();
setLookAndFeel("Metal");
list.updateUI();
setLookAndFeel("Nimbus");
list.updateUI();
} finally {
UIManager.setLookAndFeel(lf);
}
}
示例11: initComponents
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
/**
* This method is called from within the constructor to initialize the form.
*/
private void initComponents() {
table = new JXTable(createTableModel());
// table = new JXTreeTable(new ActionMapTreeTableModel(new
// JXTreeTable()));
list = new JXList(createListModel());
tree = new JXTree(createTreeModel());
// control components
nextButton = new JButton("Find next");
radioGroup = new JXRadioGroup();
inputText = new JTextField();
patternText = new JTextField();
}
示例12: 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));
}
示例13: Data
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
public Data(Framework framework){
this.Framework = framework;
this.curMatch = new Match(Framework);
roleView = new RoleDataDisplay(Framework.Window, false);
playerList.setComparator(new Comparator_PlayerLobby());
playerList.setAutoCreateRowSorter(true);
playerList.setSortOrder(SortOrder.ASCENDING);
playerList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
playerList.setLayoutOrientation(JXList.VERTICAL);
playerList.setBackground(new Color(32,32,32));
playerList.setCellRenderer(Framework.Window.CellRenderer.new PlayerList());
roleSearchList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
roleSearchList.setLayoutOrientation(JList.VERTICAL);
roleSearchList.setBackground(new Color(32,32,32));
roleSearchList.setCellRenderer(Framework.Window.CellRenderer.new RoleList());
}
示例14: addAllPanel
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
private void addAllPanel(DefaultListModel model) {
final JXList list = new JXList(model);
list.addListSelectionListener(this);
list.setCellRenderer(renderer);
list.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent mouseEvent) {
if (mouseEvent.getClickCount() == 2) {
CallEntry entry = (CallEntry)list.getSelectedValue();
callHistoryFrame.dispose();
SoftPhoneManager.getInstance().getDefaultGuiManager().dial(entry.getNumber());
}
}
});
tabs.addTab(PhoneRes.getIString("phone.all"), null, new JScrollPane(list), PhoneRes.getIString("phone.allcalls"));
}
示例15: addDialedCalls
import org.jdesktop.swingx.JXList; //导入依赖的package包/类
private void addDialedCalls(DefaultListModel model) {
final JXList list = new JXList(model);
list.addListSelectionListener(this);
list.setCellRenderer(renderer);
list.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent mouseEvent) {
if (mouseEvent.getClickCount() == 2) {
CallEntry entry = (CallEntry)list.getSelectedValue();
callHistoryFrame.dispose();
SoftPhoneManager.getInstance().getDefaultGuiManager().dial(entry.getNumber());
}
}
});
List<RowFilter<Object,Object>> filters = new ArrayList<RowFilter<Object,Object>>();
filters.add(RowFilter.regexFilter(CallLog.Type.dialed.toString(), 1));
filters.add(RowFilter.regexFilter(CallLog.Type.dialed.toString(), 2));
filters.add(RowFilter.regexFilter(CallLog.Type.dialed.toString(), 3));
RowFilter<Object,Object> af = RowFilter.orFilter(filters);
list.setRowFilter(af);
tabs.addTab(PhoneRes.getIString("phone.dialed"), null, new JScrollPane(list), PhoneRes.getIString("phone.dialedcalls"));
}