本文整理汇总了Java中javax.swing.JList.setCellRenderer方法的典型用法代码示例。如果您正苦于以下问题:Java JList.setCellRenderer方法的具体用法?Java JList.setCellRenderer怎么用?Java JList.setCellRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JList
的用法示例。
在下文中一共展示了JList.setCellRenderer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ListPanel
import javax.swing.JList; //导入方法依赖的package包/类
public ListPanel(FilterModel fltrmodel, Function<T, String> mapper) {
setLayout(new java.awt.BorderLayout());
JScrollPane sp = new javax.swing.JScrollPane();
list = new JList();
list.setModel(fltrmodel);
list.setCellRenderer(new CheckBoxListRenderer(mapper));
sp.setViewportView(list);
add(sp, BorderLayout.CENTER);
list.setSelectionModel(new MultiSelectionModel(this::onSelect));
list.addKeyListener(onDelete());
list.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ctrl A"), "SelectAll");
list.getActionMap().put("SelectAll", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
list.setSelectionInterval(0, list.getModel().getSize() - 1);
}
});
}
示例2: initComponents
import javax.swing.JList; //导入方法依赖的package包/类
private void initComponents() {
setLayout(new BorderLayout());
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
listModel = new DefaultListModel();
list = new JList(listModel);
list.getAccessibleContext().setAccessibleName(Bundle.ProfilingPointsDisplayer_ListAccessName());
list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.setVisibleRowCount(6);
list.setCellRenderer(org.netbeans.modules.profiler.ppoints.Utils.getPresenterListRenderer());
JScrollPane listScroll = new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
listScroll.setPreferredSize(new Dimension(405, listScroll.getPreferredSize().height));
add(listScroll, BorderLayout.CENTER);
}
示例3: setNames
import javax.swing.JList; //导入方法依赖的package包/类
public void setNames() {
ListModel lm = new AbstractListModel() {
private static final long serialVersionUID = 1L;
String headers[] = ((JWatBivariateStatsTableModel) tab.getModel()).getNames();
public int getSize() {
return headers.length;
}
public Object getElementAt(int index) {
return headers[index];
}
};
JList rowHeader = new JList(lm);
rowHeader.setBackground(getBackground());
rowHeader.setFixedCellWidth(100);
rowHeader.setFixedCellHeight(tab.getRowHeight());
rowHeader.setCellRenderer(new RowHeaderRenderer(tab));
setRowHeaderView(rowHeader);
}
示例4: Digitizer
import javax.swing.JList; //导入方法依赖的package包/类
public Digitizer( XMap map ) {
this.map = map;
objects = new Vector<Object>();
currentObject = null;
model = new DigListModel( this );
list = new JList(model);
list.setCellRenderer( new DigCellRenderer() );
list.addListSelectionListener( this);
list.addMouseListener( this);
initTools();
enabled = false;
listening = false;
lastSelectedIndex = -1;
options = new DigitizerOptionsDialog( map );
initDialog();
profile = new DigProfile( map );
graph = new XYGraph( profile, 0);
graph.setScrollableTracksViewportHeight( true );
graph.setScrollableTracksViewportWidth( false );
graph.setAxesSides( Axes.LEFT | Axes.BOTTOM );
Zoomer zoomer = new Zoomer( graph );
graph.addMouseListener( zoomer );
graph.addMouseMotionListener( zoomer );
graph.addKeyListener( zoomer );
}
示例5: MovePanel
import javax.swing.JList; //导入方法依赖的package包/类
public MovePanel(final ChangeListener parent, String startPackage, String headLine) {
super(parent, startPackage, headLine, targetFolder != null ? targetFolder : (FileObject) mappingFileObjects[0]);
// Add a list to list the selected mapping files
if (mappingFileObjects.length > 1) {
setCombosEnabled(!disable);
JList list = new JList(getNodes());
list.setCellRenderer(new NodeRenderer());
list.setVisibleRowCount(5);
JScrollPane pane = new JScrollPane(list);
bottomPanel.setBorder(new EmptyBorder(8, 0, 0, 0));
bottomPanel.setLayout(new BorderLayout());
bottomPanel.add(pane, BorderLayout.CENTER);
JLabel listOf = new JLabel();
Mnemonics.setLocalizedText(listOf, NbBundle.getMessage(MovePanel.class, "LBL_ListOfMappingFiles"));
bottomPanel.add(listOf, BorderLayout.NORTH);
}
}
示例6: createP3
import javax.swing.JList; //导入方法依赖的package包/类
JPanel createP3() {
p3 = new JPanel(new BorderLayout());
model = new DefaultListModel();
list = new JList(model);
list.setCellRenderer(new YTListRenderer());
p3.add(new JScrollPane(list));
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
btnDwnld = new JButton("Download");
btnDwnld.addActionListener(this);
btnCancel = new JButton("Close");
btnCancel.addActionListener(this);
box.add(btnDwnld);
box.add(Box.createHorizontalStrut(10));
box.add(btnCancel);
btnCancel.setPreferredSize(btnDwnld.getPreferredSize());
box.add(Box.createHorizontalStrut(10));
box.add(Box.createRigidArea(new Dimension(0, 40)));
p3.add(box, BorderLayout.SOUTH);
box.setOpaque(true);
box.setBackground(StaticResource.titleColor);
return p3;
}
示例7: setNames
import javax.swing.JList; //导入方法依赖的package包/类
public void setNames() {
ListModel lm = new AbstractListModel() {
/**
*
*/
private static final long serialVersionUID = 1L;
String headers[] = ((JWatBivariateStatsTableModel) tab.getModel()).getNames();
public int getSize() {
return headers.length;
}
public Object getElementAt(int index) {
return headers[index];
}
};
JList rowHeader = new JList(lm);
rowHeader.setBackground(getBackground());
rowHeader.setFixedCellWidth(100);
rowHeader.setFixedCellHeight(tab.getRowHeight());
rowHeader.setCellRenderer(new RowHeaderRenderer(tab));
setRowHeaderView(rowHeader);
}
示例8: connectAvailable
import javax.swing.JList; //导入方法依赖的package包/类
public static void connectAvailable(JList availableTablesList, TableClosure tableClosure, FilterAvailable filter) {
availableTablesList.setModel(new AvailableTablesModel(tableClosure));
if (!(availableTablesList.getCellRenderer() instanceof AvailableTableRenderer)) {
availableTablesList.setCellRenderer(new AvailableTableRenderer(filter));
} else {
AvailableTableRenderer renderer = (AvailableTableRenderer) availableTablesList.getCellRenderer();
renderer.updateFilter(filter);
}
}
示例9: connectSelected
import javax.swing.JList; //导入方法依赖的package包/类
public static void connectSelected(JList selectedTablesList, TableClosure tableClosure) {
selectedTablesList.setModel(new SelectedTablesModel(tableClosure));
if (!(selectedTablesList.getCellRenderer() instanceof SelectedTableRenderer)) {
selectedTablesList.setCellRenderer(new SelectedTableRenderer());
}
}
示例10: createList
import javax.swing.JList; //导入方法依赖的package包/类
/** Creates the list that will display the data.
*/
protected JList createList() {
JList list = new NbList();
list.setCellRenderer(new NodeRenderer());
return list;
}
示例11: setupGUI
import javax.swing.JList; //导入方法依赖的package包/类
@SuppressWarnings("nls")
private void setupGUI()
{
addSelected = new JButton(">");
removeSelected = new JButton("<");
removeAll = new JButton("<<");
addSelected.addActionListener(this);
removeSelected.addActionListener(this);
removeAll.addActionListener(this);
finder = new TabbedFinder(userService, filters);
listModel = new GenericListModel<String>();
list = new JList(listModel);
list.setCellRenderer(new ExpressionListCellRenderer(userService));
JScrollPane listScroller = new JScrollPane(list);
listScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
final int height1 = addSelected.getPreferredSize().height;
final int width1 = removeAll.getPreferredSize().width;
final int width2 = 200;
final int[] rows = {TableLayout.FILL, height1, height1, height1, TableLayout.FILL,};
final int[] cols = {TableLayout.FILL, width1, width2,};
setLayout(new TableLayout(rows, cols));
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
add((Component) finder, new Rectangle(0, 0, 1, 5));
add(addSelected, new Rectangle(1, 1, 1, 1));
add(removeSelected, new Rectangle(1, 2, 1, 1));
add(removeAll, new Rectangle(1, 3, 1, 1));
add(listScroller, new Rectangle(2, 0, 1, 5));
}
示例12: ParameterizedCompletionChoicesWindow
import javax.swing.JList; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param parent The parent window (hosting the text component).
* @param ac The auto-completion instance.
* @param context The completion context.
*/
public ParameterizedCompletionChoicesWindow(Window parent,
AutoCompletion ac,
final ParameterizedCompletionContext context) {
super(parent);
this.ac = ac;
ComponentOrientation o = ac.getTextComponentOrientation();
model = new DefaultListModel();
list = new JList(model);
if (ac.getParamChoicesRenderer()!=null) {
list.setCellRenderer(ac.getParamChoicesRenderer());
}
list.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount()==2) {
context.insertSelectedChoice();
}
}
});
sp = new JScrollPane(list);
setContentPane(sp);
applyComponentOrientation(o);
setFocusableWindowState(false);
// Give apps a chance to decorate us with drop shadows, etc.
PopupWindowDecorator decorator = PopupWindowDecorator.get();
if (decorator!=null) {
decorator.decorate(this);
}
}
示例13: connectAvailable
import javax.swing.JList; //导入方法依赖的package包/类
public static void connectAvailable(JList availableTablesList, TableClosure tableClosure) {
availableTablesList.setModel(new AvailableTablesModel(tableClosure));
if (!(availableTablesList.getCellRenderer() instanceof AvailableTableRenderer)) {
availableTablesList.setCellRenderer(new AvailableTableRenderer());
}
}
示例14: createNewInfoLabelJList
import javax.swing.JList; //导入方法依赖的package包/类
/**
* Creates a new JList for info labels of a source
*
* @param source
* can be null for local source, otherwise name of the source
* @return the created JList
*/
private JList<String> createNewInfoLabelJList(String source) {
final JList<String> createdInfoLabelList = new JList<>();
createdInfoLabelList.setModel(source == null ? localInfoLabelListModel : remoteInfoLabelListModels.get(source));
createdInfoLabelList.setCellRenderer(new ConfigurableInfoLabelRenderer());
createdInfoLabelList.setFixedCellHeight(20);
createdInfoLabelList.setBackground(LIGHTER_GRAY);
return createdInfoLabelList;
}
示例15: buildChooser
import javax.swing.JList; //导入方法依赖的package包/类
@Override
public void buildChooser() {
setLayout(new BorderLayout());// GridLayout(0, 1));
if (!itens.isEmpty()) {
JScrollPane jsp = new javax.swing.JScrollPane();
lst = new JList(itens.toArray(new Legenda.ItemDeLegenda[]{}));
add(jsp, BorderLayout.EAST);
jsp.add(lst);
jsp.setViewportView(lst);
lst.setModel(new javax.swing.AbstractListModel() {
@Override
public int getSize() {
return itens.size();
}
@Override
public Object getElementAt(int i) {
return itens.get(i);
}
});
lst.addListSelectionListener( e -> {
if (e == null || lst.getSelectedIndex() < 0) {
return;
}
Legenda.ItemDeLegenda r = itens.get(lst.getSelectedIndex());
getColorSelectionModel().setSelectedColor(r.getCor());
});
lst.setCellRenderer(new JListItemParaItemLegenda(false));
}
}