iconnode.java

来自「Java中Swing界面库中几个类使用的例子」· Java 代码 · 共 60 行

JAVA
60
字号
/*  (swing1.1.1beta2) */ package jp.gr.java_conf.tame.swing.tree;import java.util.*;import javax.swing.*;import javax.swing.tree.*;/** * @version 1.1 06/19/99 */public class IconNode extends DefaultMutableTreeNode  {  protected Icon   icon;  protected String iconName;  public IconNode() {    this(null);  }  public IconNode(Object userObject) {    this(userObject, true, null);  }  public IconNode(Object userObject, boolean allowsChildren		       , Icon icon) {    super(userObject, allowsChildren);    this.icon = icon;  }  public void setIcon(Icon icon) {    this.icon = icon;  }    public Icon getIcon() {    return icon;  }    public String getIconName() {    if (iconName != null) {      return iconName;    } else {      String str = userObject.toString();      int index = str.lastIndexOf(".");      if (index != -1) {        return str.substring(++index);      } else {        return null;      }      }  }    public void setIconName(String name) {    iconName = name;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?