本文整理匯總了Java中javax.swing.tree.DefaultTreeCellRenderer.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTreeCellRenderer.setText方法的具體用法?Java DefaultTreeCellRenderer.setText怎麽用?Java DefaultTreeCellRenderer.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.tree.DefaultTreeCellRenderer
的用法示例。
在下文中一共展示了DefaultTreeCellRenderer.setText方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
@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;
}
示例3: 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;
}