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


Java DefaultListCellRenderer类代码示例

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


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

示例1: FoldOptionsPanel

import javax.swing.DefaultListCellRenderer; //导入依赖的package包/类
/**
 * Creates new form FoldOptionsPanel
 */
public FoldOptionsPanel(FoldOptionsController ctrl) {
    this.ctrl = ctrl;
    initComponents();
    
    langSelect.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof String[]) {
                value = ((String[])value)[1];
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
        }
    });
    langSelect.addActionListener(this);
    contentPreview.addActionListener(this);
    foldedSummary.addActionListener(this);
    
    // preferences should be set as a reaction to index selection
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FoldOptionsPanel.java

示例2: UpdateUIRecursionTest

import javax.swing.DefaultListCellRenderer; //导入依赖的package包/类
public UpdateUIRecursionTest() {
    super("UpdateUIRecursionTest");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 400);

    String[] listData = {
        "First", "Second", "Third", "Fourth", "Fifth", "Sixth"
    };

    list = new JList(listData);
    list.setCellRenderer(this);
    renderer = new DefaultListCellRenderer();
    getContentPane().add(new JScrollPane(list), BorderLayout.CENTER);

    setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:UpdateUIRecursionTest.java

示例3: createSelectorsRenderer

import javax.swing.DefaultListCellRenderer; //导入依赖的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

示例4: createStylesheetsRenderer

import javax.swing.DefaultListCellRenderer; //导入依赖的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) {
                    //empty model
                    return c;
                }
                FileObject file = (FileObject) value;
                String fileNameExt = file.getNameExt();
                setText(fileNameExt);

//                if(file.equals(context)) {
//                    StringBuilder sb = new StringBuilder();
//                    sb.append("<html><body><b>"); //NOI18N
//                    sb.append(fileNameExt);
//                    sb.append("</b></body></html>"); //NOI18N
//                    setText(sb.toString());
//                } else {
//                    setText(fileNameExt);
//                }
                return c;
            }
        };
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:EditRulesPanel.java

示例5: createAtRulesRenderer

import javax.swing.DefaultListCellRenderer; //导入依赖的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

示例6: ShowEffPomDiffPanel

import javax.swing.DefaultListCellRenderer; //导入依赖的package包/类
/**
 * Creates new form ShowEffPomDiffPanel
 */
public ShowEffPomDiffPanel(ProjectConfigurationProvider<MavenConfiguration> configs) {
    initComponents();
    ComboBoxModel<MavenConfiguration> model = new DefaultComboBoxModel<MavenConfiguration>(configs.getConfigurations().toArray(new MavenConfiguration[0]));
    comConfiguration.setModel(model);
    comConfiguration.setEditable(false);
    comConfiguration.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            return super.getListCellRendererComponent(list, ((ProjectConfiguration)value).getDisplayName(), index, isSelected, cellHasFocus);
        }
    });
    comConfiguration.setSelectedItem(configs.getActiveConfiguration());
    enableFields();
    epProperties.setContentType("text/x-properties");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ShowEffPomDiffPanel.java

示例7: Unshelve

import javax.swing.DefaultListCellRenderer; //导入依赖的package包/类
public Unshelve () {
    panel = new UnshelveChangesPanel();
    panel.cmbPatches.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof Patch) {
                value = ((Patch) value).getPatchName();
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }
    });
    unshelveButton = new JButton();
    removeButton = new JButton();
    panel.cmbPatches.addActionListener(this);
    initializePatches();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:UnshelveChangesAction.java

示例8: createStyleSheetsRenderer

import javax.swing.DefaultListCellRenderer; //导入依赖的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

示例9: OnSaveTabPanel

import javax.swing.DefaultListCellRenderer; //导入依赖的package包/类
public OnSaveTabPanel() {
    initComponents();
    // Languages combobox renderer
    cboLanguage.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if ((value instanceof String) && selector != null) {
                value = selector.getLanguageName((String) value);
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }
    });
    
    commonPanel = new OnSaveCommonPanel();
    commonPanelContainer.setLayout(new BorderLayout());
    commonPanelContainer.add(commonPanel, BorderLayout.WEST);
    
    customPanelContainer.setLayout(new BorderLayout());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:OnSaveTabPanel.java

示例10: FolderBasedOptionPanel

import javax.swing.DefaultListCellRenderer; //导入依赖的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

示例11: CodeCompletionOptionsPanel

import javax.swing.DefaultListCellRenderer; //导入依赖的package包/类
/** 
 * Creates new form CodeCompletionOptionsPanel.
 */
public CodeCompletionOptionsPanel () {
    initComponents ();

    // Languages combobox renderer
    cbLanguage.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof String) {
                value = ((String)value).length() > 0
                        ? EditorSettings.getDefault().getLanguageName((String)value)
                        : org.openide.util.NbBundle.getMessage(CodeCompletionOptionsPanel.class, "LBL_AllLanguages"); //NOI18N
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }
    });

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:CodeCompletionOptionsPanel.java

示例12: CharsetSelector

import javax.swing.DefaultListCellRenderer; //导入依赖的package包/类
public CharsetSelector() {
    super(
            Charset.availableCharsets().values().toArray(new Charset[]{})
    );
    this.setRenderer(new DefaultListCellRenderer(){

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Object displayValue;
            if(value instanceof Charset) {
                displayValue = ((Charset) value).displayName();
            } else {
                displayValue = value;
            }
            return super.getListCellRendererComponent(list, displayValue, index, isSelected, cellHasFocus);
        }
        
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CharsetSelector.java

示例13: getLabelComboBox

import javax.swing.DefaultListCellRenderer; //导入依赖的package包/类
/** Returns the combo box for the label in the given type graph. */
private JComboBox<TypeLabel> getLabelComboBox(TypeGraph typeGraph) {
    final JComboBox<TypeLabel> result = new JComboBox<>();
    result.setFocusable(false);
    result.setRenderer(new DefaultListCellRenderer() {
        @SuppressWarnings("rawtypes")
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index,
            boolean isSelected, boolean cellHasFocus) {
            if (value instanceof TypeLabel) {
                value = HTMLConverter.HTML_TAG.on(((TypeLabel) value).toLine().toHTMLString());
            }
            return super.getListCellRendererComponent(list,
                value,
                index,
                isSelected,
                cellHasFocus);
        }
    });
    for (TypeLabel label : sortLabels(typeGraph.getLabels())) {
        if (!label.isDataType() && label != TypeLabel.NODE) {
            result.addItem(label);
        }
    }
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:27,代码来源:FindReplaceDialog.java

示例14: DisplayNodeList

import javax.swing.DefaultListCellRenderer; //导入依赖的package包/类
public DisplayNodeList(final SchemaModel schemaModel, final boolean extrasVisible)
{
	super(true);

	this.schemaModel = schemaModel;
	this.extrasVisible = extrasVisible;

	setListCellRenderer(new DefaultListCellRenderer()
	{
		@Override
		public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
			boolean cellHasFocus)
		{
			super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
			String title = CurrentLocale.get(((DisplayNode) value).getTitle(), null);
			setText(title != null ? title : UNTITLED);
			return this;
		}
	});
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:DisplayNodeList.java

示例15: createRenderer

import javax.swing.DefaultListCellRenderer; //导入依赖的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


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