本文整理匯總了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;
}