Java Code Examples for javax.swing.ListCellRenderer

The following examples show how to use javax.swing.ListCellRenderer. These examples are extracted from open source projects. 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
/**
 * {@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 Project: netbeans   Source File: FolderBasedOptionPanel.java    License: Apache License 2.0 6 votes vote down vote up
/** 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 3
Source Project: netbeans   Source File: FileSearchAction.java    License: Apache License 2.0 6 votes vote down vote up
@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 4
Source Project: netbeans   Source File: CustomizerIncludePath.java    License: Apache License 2.0 6 votes vote down vote up
@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 5
Source Project: openAGV   Source File: SelectionPropertyEditorPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form SelectionPropertyEditorPanel
 */
@SuppressWarnings("unchecked")
public SelectionPropertyEditorPanel(ListCellRenderer<?> listCellRenderer) {
  requireNonNull(listCellRenderer, "listCellRenderer");
  
  this.listCellRenderer = (ListCellRenderer<Object>) listCellRenderer;
  initComponents();
}
 
Example 6
Source Project: FlatLaf   Source File: UIDefaultsDump.java    License: Apache License 2.0 5 votes vote down vote up
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 7
Source Project: FlatLaf   Source File: FlatComboBoxUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Dimension getDefaultSize() {
	@SuppressWarnings( "unchecked" )
	ListCellRenderer<Object> renderer = comboBox.getRenderer();
	uninstallCellPaddingBorder( renderer );

	Dimension size = super.getDefaultSize();

	uninstallCellPaddingBorder( renderer );
	return size;
}
 
Example 8
Source Project: openjdk-jdk9   Source File: Test7195179.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 Project: dragonwell8_jdk   Source File: Test7195179.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 10
Source Project: ghidra   Source File: GListAutoLookup.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String getValueString(int row, int col) {
	ListCellRenderer<? super T> renderer = list.getCellRenderer();
	T value = list.getModel().getElementAt(row);
	if (!(renderer instanceof JLabel)) {
		return value.toString();
	}

	Component c = renderer.getListCellRendererComponent(list, value, row, false, false);
	return ((JLabel) c).getText();
}
 
Example 11
Source Project: openjdk-jdk9   Source File: JListOperator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JList.getCellRenderer()} through queue
 */
public ListCellRenderer<?> getCellRenderer() {
    return (runMapping(new MapAction<ListCellRenderer<?>>("getCellRenderer") {
        @Override
        public ListCellRenderer<?> map() {
            return ((JList) getSource()).getCellRenderer();
        }
    }));
}
 
Example 12
Source Project: TencentKona-8   Source File: Test7195179.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 13
Source Project: jdk8u60   Source File: Test7195179.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 Project: opt4j   Source File: ConvergencePlotWidget.java    License: MIT License 5 votes vote down vote up
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 15
Source Project: openjdk-jdk8u   Source File: Test7195179.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 Project: marathonv5   Source File: JListItemJavaElement.java    License: Apache License 2.0 5 votes vote down vote up
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 17
Source Project: zencash-swing-wallet-ui   Source File: DashboardPanel.java    License: MIT License 5 votes vote down vote up
@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 18
Source Project: netbeans   Source File: TestCategory.java    License: Apache License 2.0 5 votes vote down vote up
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 19
Source Project: netbeans   Source File: ViewTooltips.java    License: Apache License 2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example 20
Source Project: netbeans   Source File: ModifyElementRulesPanel.java    License: Apache License 2.0 5 votes vote down vote up
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 21
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 Project: netbeans   Source File: GoToTypeAction.java    License: Apache License 2.0 5 votes vote down vote up
@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 23
Source Project: netbeans   Source File: PhpProjectProperties.java    License: Apache License 2.0 5 votes vote down vote up
public ListCellRenderer<BasePathSupport.Item> getIncludePathListRenderer() {
    if (includePathListRenderer == null) {
        includePathListRenderer = new PathUiSupport.ClassPathListCellRenderer(ProjectPropertiesSupport.getPropertyEvaluator(project),
            project.getProjectDirectory());
    }
    return includePathListRenderer;
}
 
Example 24
Source Project: netbeans   Source File: PhpProjectProperties.java    License: Apache License 2.0 5 votes vote down vote up
public ListCellRenderer<BasePathSupport.Item> getCodeAnalysisExcludesListModelListRenderer() {
    if (codeAnalysisExcludesListRenderer == null) {
        codeAnalysisExcludesListRenderer = new PathUiSupport.ClassPathListCellRenderer(ProjectPropertiesSupport.getPropertyEvaluator(project),
            project.getProjectDirectory());
    }
    return codeAnalysisExcludesListRenderer;
}
 
Example 25
Source Project: netbeans   Source File: PhpProjectProperties.java    License: Apache License 2.0 5 votes vote down vote up
public ListCellRenderer<BasePathSupport.Item> getTestDirectoriesListRenderer() {
    if (testDirectoriesListRenderer == null) {
        testDirectoriesListRenderer = new PathUiSupport.ClassPathListCellRenderer(ProjectPropertiesSupport.getPropertyEvaluator(project),
            project.getProjectDirectory());
    }
    return testDirectoriesListRenderer;
}
 
Example 26
Source Project: netbeans   Source File: PhpProjectProperties.java    License: Apache License 2.0 5 votes vote down vote up
public ListCellRenderer<BasePathSupport.Item> getSeleniumTestDirectoriesListRenderer() {
    if (seleniumTestDirectoriesListRenderer == null) {
        seleniumTestDirectoriesListRenderer = new PathUiSupport.ClassPathListCellRenderer(ProjectPropertiesSupport.getPropertyEvaluator(project),
            project.getProjectDirectory());
    }
    return seleniumTestDirectoriesListRenderer;
}
 
Example 27
Source Project: netbeans   Source File: CustomizerIncludePathInternal.java    License: Apache License 2.0 5 votes vote down vote up
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 28
Source Project: freecol   Source File: BuildQueuePanel.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 29
Source Project: openjdk-jdk9   Source File: JListOperator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 30
Source Project: netbeans   Source File: CreateRulePanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
        }
    };
}