当前位置: 首页>>代码示例>>Java>>正文


Java ListCellRenderer类代码示例

本文整理汇总了Java中javax.swing.ListCellRenderer的典型用法代码示例。如果您正苦于以下问题:Java ListCellRenderer类的具体用法?Java ListCellRenderer怎么用?Java ListCellRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ListCellRenderer类属于javax.swing包,在下文中一共展示了ListCellRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSelectorsRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
private ListCellRenderer createSelectorsRenderer() {
        return new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                if (value != null) {
                    SelectorItemRenderer selectorModelItemRenderer = getSelectorModelItemRenderer();
                    selectorModelItemRenderer.setItem((SelectorItem) value, isSelected);
                    return selectorModelItemRenderer;

//                    setText(item.getDisplayName());
                }
                return c;
            }
        };
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:EditRulesPanel.java

示例2: createAtRulesRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
/**
 * Creates a renderer for the at-rules combobox dropdown.
 */   
private ListCellRenderer createAtRulesRenderer() {
    return new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value == null) {
                setText(Bundle.none_item());
            } else if(value instanceof AtRuleItem) {
                setText(((AtRuleItem) value).getDisplayName());
            } else if(value instanceof String) {
                setText((String)value);
            }
            return c;
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CreateRulePanel.java

示例3: getListCellRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
@Override
@NonNull
public ListCellRenderer getListCellRenderer(
        @NonNull final JList list,
        @NonNull final Document nameDocument,
        @NonNull final ButtonModel caseSensitive,
        @NonNull final ButtonModel colorPrefered) {
    Parameters.notNull("list", list);   //NOI18N
    Parameters.notNull("nameDocument", nameDocument);   //NOI18N
    Parameters.notNull("caseSensitive", caseSensitive); //NOI18N
    return ItemRenderer.Builder.create(
                list,
                caseSensitive,
                new FileDescriptorConvertor(nameDocument)).
            setCamelCaseSeparator(CAMEL_CASE_SEPARATOR).
            setColorPreferedProject(colorPrefered).
            build();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:FileSearchAction.java

示例4: createStyleSheetsRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
private ListCellRenderer createStyleSheetsRenderer() {
    return new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value == null) {
                setText("<html>" + Bundle.none_item());
            } else {
                FileObject file = (FileObject) value;
                FileObject webRoot = ProjectWebRootQuery.getWebRoot(file);

                String file2string;
                if (webRoot != null) {
                    file2string = FileUtil.getRelativePath(webRoot, file);
                } else {
                    file2string = FileUtil.getFileDisplayName(file);
                }

                setText(file2string);
            }
            return c;
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ModifyElementRulesPanel.java

示例5: FolderBasedOptionPanel

import javax.swing.ListCellRenderer; //导入依赖的package包/类
/** Creates new form FolderBasedOptionPanel */
FolderBasedOptionPanel(FolderBasedController controller, Document filterDocument, boolean allowFiltering) {
    this.controller = controller;

    initComponents();

    filter.setDocument(filterDocument);

    if (!allowFiltering) {
        filter.setVisible(false);
        filterLabel.setVisible(false);
    }
    
    ListCellRenderer renderer = new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof String)
                value = EditorSettings.getDefault().getLanguageName((String)value);
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }
    };
    languageCombo.setRenderer(renderer);
    languageCombo.addActionListener(this);

    update();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:FolderBasedOptionPanel.java

示例6: getRendererComponent

import javax.swing.ListCellRenderer; //导入依赖的package包/类
public static Component getRendererComponent(JList list, int item) {
    Object value = list.getModel().getElementAt(item);
    ListCellRenderer cellRenderer = list.getCellRenderer();
    Component rendererComponent = cellRenderer.getListCellRendererComponent(list, value, item, false, false);
    if (rendererComponent == null) {
        return null;
    }
    return rendererComponent;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:10,代码来源:JListItemJavaElement.java

示例7: getListCellRendererComponent

import javax.swing.ListCellRenderer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Component getListCellRendererComponent(JList list, Object value,
					int index, boolean selected, boolean hasFocus) {
	Completion c = (Completion)value;
	CompletionProvider p = c.getProvider();
	ListCellRenderer r = p.getListCellRenderer();
	if (r!=null) {
		return r.getListCellRendererComponent(list, value, index, selected,
												hasFocus);
	}
	if (fallback==null) {
		return super.getListCellRendererComponent(list, value, index,
											selected, hasFocus);
	}
	return fallback.getListCellRendererComponent(list, value, index,
												selected, hasFocus);
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:21,代码来源:DelegatingCellRenderer.java

示例8: createRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
private ListCellRenderer createRenderer()
{
   return new DefaultListCellRenderer()
   {
      private final Component SEPARATOR = new SeparatorComponent();

      public Component getListCellRendererComponent( JList list,
            Object value, int index, boolean isSelected, boolean cellHasFocus)
      {
         if ( value instanceof ComboItem )
         {
            value = ((ComboItem)value).getDelegate();
         }

         if ( value == null )
         {
            return SEPARATOR;
         }
         return super.getListCellRendererComponent( list, value, index, 
               isSelected, cellHasFocus );
      }
   };
}
 
开发者ID:anadrome,项目名称:word-constraints,代码行数:24,代码来源:SepComboBox.java

示例9: getBestPopupSizeForRowCount

import javax.swing.ListCellRenderer; //导入依赖的package包/类
protected Dimension getBestPopupSizeForRowCount(final int maxRowCount) {
    final int currentElementCount = comboBox.getModel().getSize();
    final int rowCount = Math.min(maxRowCount, currentElementCount);

    final Dimension popupSize = new Dimension();
    final ListCellRenderer<Object> renderer = list.getCellRenderer();

    for (int i = 0; i < rowCount; i++) {
        final Object value = list.getModel().getElementAt(i);
        final Component c = renderer.getListCellRendererComponent(list, value, i, false, false);

        final Dimension prefSize = c.getPreferredSize();
        popupSize.height += prefSize.height;
        popupSize.width = Math.max(prefSize.width, popupSize.width);
    }

    popupSize.width += 10;

    return popupSize;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:AquaComboBoxPopup.java

示例10: getCellRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
public ListCellRenderer getCellRenderer() {
       return new DefaultListCellRenderer()  {

    public Component getListCellRendererComponent(
      JList list,
      Object value,            // value to display
      int index,               // cell index
      boolean isSelected,      // is the cell selected
      boolean cellHasFocus)    // the list and the cell have the focus
    {
        JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        String s = value.toString();
        label.setText(s);
        //Note currentNote = CurrentProject.getNoteList().getActiveNote();
	 Note currentNote = CurrentNote.get();
        if (currentNote != null) {
           if (getNote(index).getId().equals(currentNote.getId()))
               label.setFont(label.getFont().deriveFont(Font.BOLD));
        }
        if (getNote(index).isMarked())
           label.setIcon(bookmarkIcon);
        //setIcon();
      /*if (isSelected) {
            setBackground(list.getSelectionBackground());
          setForeground(list.getSelectionForeground());
      }
        else {
          setBackground(list.getBackground());
          setForeground(list.getForeground());
      }
      setEnabled(list.isEnabled());
      setFont(list.getFont());
        setOpaque(true);*/
        label.setToolTipText(s);
        return label;
    }
   };

}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:40,代码来源:NotesList.java

示例11: createAtRulesRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
private ListCellRenderer createAtRulesRenderer() {
    return new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value == null) {
                setText(Bundle.EditRulesPanel_none_item());
            } else {
                setText(((MediaItem) value).getDisplayName());
            }
            return c;
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:EditRulesPanel.java

示例12: createSelectorsRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
/**
 * Creates a renderer for the selectors combobox dropdown.
 */
private ListCellRenderer createSelectorsRenderer() {
    return new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value != null) {
                if(value instanceof SelectorItem) {
                    SelectorItem selectorItem = (SelectorItem) value;
                    if (selectorItem == NO_CLASS || selectorItem == NO_ID) {
                        setText(Bundle.none_item());
                        return c;
                    } else {
                        SelectorItemRenderer selectorModelItemRenderer = getSelectorModelItemRenderer();
                        boolean originalElement = false;
                        switch (selectorItem.getType()) {
                            case SelectorItem.CLASS_TYPE:
                                originalElement = selectorItem.getItemName().equals(getSelectedElementClassName());
                                break;
                            case SelectorItem.ID_TYPE:
                                originalElement = selectorItem.getItemName().equals(getSelectedElementIdName());
                                break;
                        }
                        selectorModelItemRenderer.setItem(selectorItem, isSelected, originalElement);
                        return selectorModelItemRenderer;
                    }
                }
            } else if(value instanceof String) {
                setText((String)value);
            }
            return c;
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:CreateRulePanel.java

示例13: createStylesheetsRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
/**
 * Creates a renderer for the stylesheets combobox dropdown.
 */    
private ListCellRenderer createStylesheetsRenderer() {
    return new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value == null) {
                //empty model
                return c;
            }
            if(value instanceof FileObject) {
                FileObject file = (FileObject) value;
                if(webRoot == null) {
                    setText(file.getNameExt());
                } else {
                    String relativePath = FileUtil.getRelativePath(webRoot, file);
                    if(relativePath != null) {
                        setText(relativePath);
                    } else {
                        //should not happen
                        setText(file.getNameExt());
                    }
                }
            } else if(value instanceof String) {
                setText((String)value);
            }
            
            return c;
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:CreateRulePanel.java

示例14: showJList

import javax.swing.ListCellRenderer; //导入依赖的package包/类
private void showJList (JScrollPane view, Point pt) {
    JList list = (JList) view.getViewport().getView();
    Point p = SwingUtilities.convertPoint(view, pt.x, pt.y, list);
    int row = list.locationToIndex(p);
    if (row == -1) {
        hide();
        return;
    }
    Rectangle bds = list.getCellBounds(row, 
            row);
    //GetCellBounds returns a width that is the
    //full component width;  we want only what
    //the renderer really needs.
    ListCellRenderer ren = list.getCellRenderer();
    Dimension rendererSize = 
            ren.getListCellRendererComponent(list, 
            list.getModel().getElementAt(row), 
            row, false, false).getPreferredSize();
    
    bds.width = rendererSize.width;
    if (bds == null || !bds.contains(p)) {
        hide();
        return;
    }
    if (setCompAndRow (list, row)) {
        Rectangle visible = getShowingRect (view);
        Rectangle[] rects = getRects (bds, visible);
        if (rects.length > 0) {
            ensureOldPopupsHidden();
            painter.configure(
                    list.getModel().getElementAt(row), 
                    view, list, row);
            showPopups (rects, bds, visible, list, view);
        } else {
            hide();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ViewTooltips.java

示例15: getItemRenderer

import javax.swing.ListCellRenderer; //导入依赖的package包/类
private static ListCellRenderer getItemRenderer () {
    ListCellRenderer renderer = rendererRef == null ? null : rendererRef.get ();
    if (renderer == null) {
        renderer = new ItemRenderer ();
        rendererRef = new WeakReference<ListCellRenderer>( renderer );
    }
    return renderer;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CategoryList.java


注:本文中的javax.swing.ListCellRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。