概述
======classColorTableCellRendererextendsJPanelimplementsTableCellRenderer{publicComponentgetTableCellRendererComponent(JTabletable,Objectvalue,booleanisSelected,booleanha...
======
class ColorTableCellRenderer extends JPanel implements TableCellRenderer
{
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column)
{
setBackground((Color) value);
if (hasFocus) setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
else setBorder(null);
return this;
}
}
----------------------------------
class ClassNameTreeCellRenderer extends DefaultTreeCellRenderer
{
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
boolean expanded, boolean leaf, int row, boolean hasFocus)
{
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); //这边,为什么这要先调用父类的这个函数,作用是什么,为什么有时候不用
// get the user object
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
Class> c = (Class>) node.getUserObject();
// the first time, derive italic font from plain font
if (plainFont == null)
{
plainFont = getFont();
// the tree cell renderer is sometimes called with a label that has a null font
if (plainFont != null) italicFont = plainFont.deriveFont(Font.ITALIC);
}
// set font to italic if the class is abstract, plain otherwise
if ((c.getModifiers() & Modifier.ABSTRACT) == 0) setFont(plainFont);
else setFont(italicFont);
return this;
}
===========================
展开
最后
以上就是冷艳飞机为你收集整理的java render()_java中的绘制器Renderer的问题?的全部内容,希望文章能够帮你解决java render()_java中的绘制器Renderer的问题?所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复