?? categorytreecellrenderer.java
字號:
package net.robin.crm.ui;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import net.robin.crm.service.Category;
import net.robin.crm.service.Company;
public class CategoryTreeCellRenderer extends DefaultTreeCellRenderer {
private ImageIcon rootIcon;
private ImageIcon categoryIcon;
private ImageIcon companyIcon;
// private boolean hasFocus;
//
public CategoryTreeCellRenderer() {
super();
}
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
row, hasFocus);
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
Object userObject = node.getUserObject();
//處理根節點!
if (node instanceof CategoryRootTreeNode) {
if(rootIcon!=null){
setIcon(rootIcon);
}
}
if (userObject instanceof Category) {
if(categoryIcon!=null){
setIcon(categoryIcon);
}
}
if (userObject instanceof Company) {
if(companyIcon!=null){
setIcon(companyIcon);
}
}
// this.hasFocus = hasFocus;
return this;
}
// public void paint(Graphics g) {
// super.paint(g);
//
// if(hasFocus)
// g.drawString("選定了!", 0, 15);
// }
//
public ImageIcon getCategoryIcon() {
return categoryIcon;
}
public void setCategoryIcon(ImageIcon categoryIcon) {
this.categoryIcon = categoryIcon;
}
public ImageIcon getCompanyIcon() {
return companyIcon;
}
public void setCompanyIcon(ImageIcon companyIcon) {
this.companyIcon = companyIcon;
}
public ImageIcon getRootIcon() {
return rootIcon;
}
public void setRootIcon(ImageIcon rootIcon) {
this.rootIcon = rootIcon;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -