本文整理汇总了Java中javax.swing.tree.DefaultTreeCellRenderer.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeCellRenderer.setIcon方法的具体用法?Java DefaultTreeCellRenderer.setIcon怎么用?Java DefaultTreeCellRenderer.setIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultTreeCellRenderer
的用法示例。
在下文中一共展示了DefaultTreeCellRenderer.setIcon方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupForChart
import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
private void setupForChart(DefaultTreeCellRenderer r, Chart chart) {
ChartType chartType = chart.getType();
if (chartType == null) {
r.setIcon(CHART_ICON);
} else if (chartType.equals(ChartType.BAR)) {
r.setIcon(CHART_BAR_ICON);
} else if (chartType.equals(ChartType.PIE)) {
r.setIcon(CHART_PIE_ICON);
} else if (chartType.equals(ChartType.CATEGORY_LINE)) {
r.setIcon(CHART_LINE_ICON);
} else if (chartType.equals(ChartType.SCATTER)) {
r.setIcon(CHART_SCATTER_ICON);
} else if (chartType.equals(ChartType.LINE)) {
r.setIcon(CHART_LINE_ICON);
} else {
logger.warn("Using generic icon for unknown chart type " + chartType);
r.setIcon(CHART_ICON);
}
r.setText(chart.getName());
}
示例2: getTreeCellRendererComponent
import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
tree.putClientProperty(TREE_TABLE_TREE_KEY, new JBTable());
cellRenderer.setIcon(null);
return cellRenderer;
}
示例3: getTreeCellRendererComponent
import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
DefaultTreeCellRenderer cellRenderer = (JBDefaultTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
tree.putClientProperty(TREE_TABLE_TREE_KEY, new JBTable()); // Avoid setting TreeUnfocusedSelectionBackground
// Set icon
Issue topIssue = ((ScanTreeNode) value).getTopIssue();
cellRenderer.setIcon(IconUtils.load(StringUtils.lowerCase(topIssue.getSeverity().toString())));
return cellRenderer;
}
示例4: getTreeCellRendererComponent
import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
@Override
@Nonnull
public Component getTreeCellRendererComponent(@Nonnull final JTree tree, @Nonnull final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
final DefaultTreeCellRenderer result = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof Topic) {
result.setIcon(getIconForTopic((Topic) value));
result.setText(extractTextFromTopic((Topic) value));
}
return result;
}
示例5: getTreeCellRendererComponent
import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
@Override
public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
final DefaultTreeCellRenderer result = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof Topic) {
result.setIcon(getIconForTopic((Topic) value));
result.setText(extractTextFromTopic((Topic) value));
}
return result;
}