Article View: borland.public.jbuilder.java.swing
Article #12595Re: Constructor not found
From: Carl Hewitt
Date: Thu, 10 Dec 1998 00:00
Date: Thu, 10 Dec 1998 00:00
35 lines
1665 bytes
1665 bytes
are you trying to add a image to the tree or to a node in the tree. If you
are trying to add it to a node, you need to implement a TreeCellRenderer.
public class DataNodeCellDraw extends JLabel implements TreeCellRenderer {
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded,
boolean leaf, int row,
boolean hasFocus) {
if ("I want an image") {
setIcon(new ImageIcon("c:\\myimage.jpg");
setText(value.toString());
} else
setIcon(null);
setText(value.toString());
}
}
}
John Jones wrote in message <74oob5$e0811@forums.borland.com>...
>I am trying to create as class to add image to a JTree and I found several
>examples that override the paint in a class but I can not get this to work.
>What do I need to do to this class?
>
> public class MyTree extends JTree {
>
> public void paint(Graphics g){
> super.paint(g);
> Image backGroundImage =
>Toolkit.getDefaultToolkit().getImage("AGLMenuBkgd.jpg");
> Dimension d = getSize();
> g.drawImage(backGroundImage,0,0,d.width,d.height,this);
> }
> }
>
>
Technical Details
Message-ID:
<74orpc$e0k19@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<74oob5$e0811@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,66c60665803a549d X-Google-Attributes: gid111d45,public From: "Carl Hewitt" <carl@oop.com> Subject: Re: Constructor not found Date: 1998/12/10 Message-ID: <74orpc$e0k19@forums.borland.com> X-Deja-AN: 420841533 References: <74oob5$e0811@forums.borland.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing