javax.swing.ListCellRenderer Java Examples
The following examples show how to use
javax.swing.ListCellRenderer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractLanguageSupport.java From MeteoInfo with GNU Lesser General Public License v3.0 | 7 votes |
/** * {@inheritDoc} */ @Override public void setDefaultCompletionCellRenderer(ListCellRenderer r) { if (r==null) { r = createDefaultCompletionCellRenderer(); } if (r instanceof CompletionCellRenderer && Util.getUseSubstanceRenderers()) { if (UIManager.getLookAndFeel().getClass().getName(). contains(".Substance")) { CompletionCellRenderer ccr = (CompletionCellRenderer)r; delegateToSubstanceRenderer(ccr); } } renderer = r; }
Example #2
Source File: FileSearchAction.java From netbeans with Apache License 2.0 | 6 votes |
@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(); }
Example #3
Source File: CustomizerIncludePath.java From netbeans with Apache License 2.0 | 6 votes |
@NbBundle.Messages({ "CustomizerIncludePath.tab.public.title=Shared", "CustomizerIncludePath.tab.private.title=Private", }) private void init() { ListCellRenderer<BasePathSupport.Item> includePathListRenderer = uiProps.getIncludePathListRenderer(); ChangeListener defaultChangeListener = new DefaultChangeListener(); // include paths CustomizerIncludePathInternal publicIncludePath = new CustomizerIncludePathInternal(project, publicIncludePathListModel, includePathListRenderer, LastUsedFolders.PROJECT_INCLUDE_PATH); CustomizerIncludePathInternal privateIncludePath = new CustomizerIncludePathInternal(project, privateIncludePathListModel, includePathListRenderer, LastUsedFolders.PROJECT_PRIVATE_INCLUDE_PATH); // listeners publicIncludePath.addChangeListener(defaultChangeListener); privateIncludePath.addChangeListener(defaultChangeListener); // tabs includePathTabbedPane.add(Bundle.CustomizerIncludePath_tab_public_title(), publicIncludePath); includePathTabbedPane.add(Bundle.CustomizerIncludePath_tab_private_title(), privateIncludePath); // initial validation validateData(); }
Example #4
Source File: FolderBasedOptionPanel.java From netbeans with Apache License 2.0 | 6 votes |
/** 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(); }
Example #5
Source File: GoToTypeAction.java From netbeans with Apache License 2.0 | 5 votes |
@Override public ListCellRenderer getListCellRenderer( @NonNull final JList list, @NonNull final ButtonModel caseSensitive) { Parameters.notNull("list", list); //NOI18N Parameters.notNull("caseSensitive", caseSensitive); //NOI18N return ItemRenderer.Builder.create( list, caseSensitive, new TypeDescriptorConvertor()).build(); }
Example #6
Source File: Test7195179.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { invokeAndWait(new Runnable() { @Override public void run() { Integer[] items = {null, 1, 2, 3}; JComboBox<Integer> combo = new JComboBox<>(items); JLabel label = new JLabel("choose:"); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); label.setLabelFor(combo); combo.setSelectedIndex(0); combo.setRenderer(new ListCellRenderer<Integer>() { private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); @Override public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) { return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); layout.setHorizontalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup().addComponent(label)) .addGroup(layout.createParallelGroup().addComponent(combo))); layout.setVerticalGroup(layout .createSequentialGroup() .addGroup(layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(label) .addComponent(combo))); JFrame frame = new JFrame(getClass().getSimpleName()); frame.add(panel); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); } }); }
Example #7
Source File: JListOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Maps {@code JList.setCellRenderer(ListCellRenderer)} through queue */ @SuppressWarnings(value = "unchecked") public void setCellRenderer(final ListCellRenderer<?> listCellRenderer) { runMapping(new MapVoidAction("setCellRenderer") { @Override public void map() { ((JList) getSource()).setCellRenderer(listCellRenderer); } }); }
Example #8
Source File: Test7195179.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { invokeAndWait(new Runnable() { @Override public void run() { Integer[] items = {null, 1, 2, 3}; JComboBox<Integer> combo = new JComboBox<>(items); JLabel label = new JLabel("choose:"); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); label.setLabelFor(combo); combo.setSelectedIndex(0); combo.setRenderer(new ListCellRenderer<Integer>() { private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); @Override public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) { return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); layout.setHorizontalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup().addComponent(label)) .addGroup(layout.createParallelGroup().addComponent(combo))); layout.setVerticalGroup(layout .createSequentialGroup() .addGroup(layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(label) .addComponent(combo))); JFrame frame = new JFrame(getClass().getSimpleName()); frame.add(panel); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); } }); }
Example #9
Source File: UIDefaultsDump.java From FlatLaf with Apache License 2.0 | 5 votes |
private void dumpValue( PrintWriter out, Object value ) { if( value == null || value instanceof String || value instanceof Number || value instanceof Boolean ) { out.print( value ); } else if( value instanceof Character ) { char ch = ((Character)value).charValue(); if( ch >= ' ' && ch <= '~' ) out.printf( "'%c'", value ); else out.printf( "'\\u%h'", (int) ch ); } else if( value.getClass().isArray() ) dumpArray( out, value ); else if( value instanceof List ) dumpList( out, (List<?>) value ); else if( value instanceof Color ) dumpColor( out, (Color) value ); else if( value instanceof Font ) dumpFont( out, (Font) value ); else if( value instanceof Insets ) dumpInsets( out, (Insets) value ); else if( value instanceof Dimension ) dumpDimension( out, (Dimension) value ); else if( value instanceof Border ) dumpBorder( out, (Border) value, null ); else if( value instanceof Icon ) dumpIcon( out, (Icon) value ); else if( value instanceof ListCellRenderer ) dumpListCellRenderer( out, (ListCellRenderer<?>) value ); else if( value instanceof InputMap ) dumpInputMap( out, (InputMap) value, null ); else if( value instanceof LazyValue ) dumpLazyValue( out, (LazyValue) value ); else if( value instanceof ActiveValue ) dumpActiveValue( out, (ActiveValue) value ); else out.printf( "[unknown type] %s", dumpClass( value ) ); }
Example #10
Source File: FlatComboBoxUI.java From FlatLaf with Apache License 2.0 | 5 votes |
@Override protected Dimension getDefaultSize() { @SuppressWarnings( "unchecked" ) ListCellRenderer<Object> renderer = comboBox.getRenderer(); uninstallCellPaddingBorder( renderer ); Dimension size = super.getDefaultSize(); uninstallCellPaddingBorder( renderer ); return size; }
Example #11
Source File: Merge.java From netbeans with Apache License 2.0 | 5 votes |
private ListCellRenderer createTypeRenderer() { return new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if(value instanceof MergeType) { setText(((MergeType)value).getDisplayName()); } return this; } }; }
Example #12
Source File: CategoryList.java From netbeans with Apache License 2.0 | 5 votes |
private static ListCellRenderer getItemRenderer () { ListCellRenderer renderer = rendererRef == null ? null : rendererRef.get (); if (renderer == null) { renderer = new ItemRenderer (); rendererRef = new WeakReference<ListCellRenderer>( renderer ); } return renderer; }
Example #13
Source File: Test7195179.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { invokeAndWait(new Runnable() { @Override public void run() { Integer[] items = {null, 1, 2, 3}; JComboBox<Integer> combo = new JComboBox<>(items); JLabel label = new JLabel("choose:"); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); label.setLabelFor(combo); combo.setSelectedIndex(0); combo.setRenderer(new ListCellRenderer<Integer>() { private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); @Override public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) { return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); layout.setHorizontalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup().addComponent(label)) .addGroup(layout.createParallelGroup().addComponent(combo))); layout.setVerticalGroup(layout .createSequentialGroup() .addGroup(layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(label) .addComponent(combo))); JFrame frame = new JFrame(getClass().getSimpleName()); frame.add(panel); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); } }); }
Example #14
Source File: CreateRulePanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * 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; } }; }
Example #15
Source File: Test7195179.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { invokeAndWait(new Runnable() { @Override public void run() { Integer[] items = {null, 1, 2, 3}; JComboBox<Integer> combo = new JComboBox<>(items); JLabel label = new JLabel("choose:"); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); label.setLabelFor(combo); combo.setSelectedIndex(0); combo.setRenderer(new ListCellRenderer<Integer>() { private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); @Override public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) { return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); layout.setHorizontalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup().addComponent(label)) .addGroup(layout.createParallelGroup().addComponent(combo))); layout.setVerticalGroup(layout .createSequentialGroup() .addGroup(layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(label) .addComponent(combo))); JFrame frame = new JFrame(getClass().getSimpleName()); frame.add(panel); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); } }); }
Example #16
Source File: CreateRulePanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * 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; } }; }
Example #17
Source File: PhpProjectProperties.java From netbeans with Apache License 2.0 | 5 votes |
public ListCellRenderer<BasePathSupport.Item> getSeleniumTestDirectoriesListRenderer() { if (seleniumTestDirectoriesListRenderer == null) { seleniumTestDirectoriesListRenderer = new PathUiSupport.ClassPathListCellRenderer(ProjectPropertiesSupport.getPropertyEvaluator(project), project.getProjectDirectory()); } return seleniumTestDirectoriesListRenderer; }
Example #18
Source File: BuildQueuePanel.java From freecol with GNU General Public License v2.0 | 5 votes |
/** * Set the correct cell renderer in the buildables lists. */ private void updateDetailView() { ListCellRenderer<BuildableType> cellRenderer = (this.compactBox.isSelected()) ? new FreeColComboBoxRenderer<BuildableType>() : new DefaultBuildQueueCellRenderer(); this.buildQueueList.setCellRenderer(cellRenderer); this.buildingList.setCellRenderer(cellRenderer); this.unitList.setCellRenderer(cellRenderer); }
Example #19
Source File: PhpProjectProperties.java From netbeans with Apache License 2.0 | 5 votes |
public ListCellRenderer<BasePathSupport.Item> getIncludePathListRenderer() { if (includePathListRenderer == null) { includePathListRenderer = new PathUiSupport.ClassPathListCellRenderer(ProjectPropertiesSupport.getPropertyEvaluator(project), project.getProjectDirectory()); } return includePathListRenderer; }
Example #20
Source File: ConvergencePlotWidget.java From opt4j with MIT License | 5 votes |
public ObjectiveDropDown() { super(); setRenderer(new ListCellRenderer<Objective>() { protected DefaultListCellRenderer renderer = new DefaultListCellRenderer(); @Override public Component getListCellRendererComponent(JList<? extends Objective> list, Objective value, int index, boolean isSelected, boolean cellHasFocus) { JLabel cell = (JLabel) renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); Objective objective = value; cell.setText((objective != null ? "objective: " + objective.getName() : "")); return cell; } }); setMaximumSize(getPreferredSize()); }
Example #21
Source File: Test7195179.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { invokeAndWait(new Runnable() { @Override public void run() { Integer[] items = {null, 1, 2, 3}; JComboBox<Integer> combo = new JComboBox<>(items); JLabel label = new JLabel("choose:"); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); label.setLabelFor(combo); combo.setSelectedIndex(0); combo.setRenderer(new ListCellRenderer<Integer>() { private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); @Override public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) { return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); layout.setHorizontalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup().addComponent(label)) .addGroup(layout.createParallelGroup().addComponent(combo))); layout.setVerticalGroup(layout .createSequentialGroup() .addGroup(layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(label) .addComponent(combo))); JFrame frame = new JFrame(getClass().getSimpleName()); frame.add(panel); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); } }); }
Example #22
Source File: JListItemJavaElement.java From marathonv5 with Apache License 2.0 | 5 votes |
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; } if (rendererComponent instanceof JComponent) { ((JComponent) rendererComponent).putClientProperty("jlist", (JList) list); ((JComponent) rendererComponent).putClientProperty("item", item); } return rendererComponent; }
Example #23
Source File: PhpProjectProperties.java From netbeans with Apache License 2.0 | 5 votes |
public ListCellRenderer<BasePathSupport.Item> getCodeAnalysisExcludesListModelListRenderer() { if (codeAnalysisExcludesListRenderer == null) { codeAnalysisExcludesListRenderer = new PathUiSupport.ClassPathListCellRenderer(ProjectPropertiesSupport.getPropertyEvaluator(project), project.getProjectDirectory()); } return codeAnalysisExcludesListRenderer; }
Example #24
Source File: SelectionPropertyEditorPanel.java From openAGV with Apache License 2.0 | 5 votes |
/** * Creates new form SelectionPropertyEditorPanel */ @SuppressWarnings("unchecked") public SelectionPropertyEditorPanel(ListCellRenderer<?> listCellRenderer) { requireNonNull(listCellRenderer, "listCellRenderer"); this.listCellRenderer = (ListCellRenderer<Object>) listCellRenderer; initComponents(); }
Example #25
Source File: DashboardPanel.java From zencash-swing-wallet-ui with MIT License | 5 votes |
@Override public ListCellRenderer<String[]> getCellRenderer() { return new ListCellRenderer<String[]>() { @Override public Component getListCellRendererComponent( JList<? extends String[]> list, String[] data, int index, boolean isSelected, boolean cellHasFocus) { return new SingleTransactionPanel(data); } }; }
Example #26
Source File: PhpProjectProperties.java From netbeans with Apache License 2.0 | 5 votes |
public ListCellRenderer<BasePathSupport.Item> getTestDirectoriesListRenderer() { if (testDirectoriesListRenderer == null) { testDirectoriesListRenderer = new PathUiSupport.ClassPathListCellRenderer(ProjectPropertiesSupport.getPropertyEvaluator(project), project.getProjectDirectory()); } return testDirectoriesListRenderer; }
Example #27
Source File: ModifyElementRulesPanel.java From netbeans with Apache License 2.0 | 5 votes |
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; } }; }
Example #28
Source File: CustomizerIncludePathInternal.java From netbeans with Apache License 2.0 | 5 votes |
CustomizerIncludePathInternal(PhpProject project, DefaultListModel<BasePathSupport.Item> includePathListModel, ListCellRenderer<BasePathSupport.Item> includePathListRenderer, String lastFolderKey) { assert project != null; assert includePathListModel != null; assert includePathListRenderer != null; assert lastFolderKey != null; initComponents(); init(project, includePathListModel, includePathListRenderer, lastFolderKey); }
Example #29
Source File: TestCategory.java From netbeans with Apache License 2.0 | 5 votes |
private ListCellRenderer<Object> runBuildRenderer() { return new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof RunBuild) { value = runBuildDisplayName.getOrDefault(value, String.valueOf(value)); } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }; }
Example #30
Source File: ViewTooltips.java From netbeans with Apache License 2.0 | 5 votes |
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(); } } }