About the picture that VE draws in the editor. [message #26268] |
Thu, 18 March 2004 03:00  |
Eclipse User |
|
|
|
Hi.
When I drag and drop a visual object over a JFrame (for example), VE draws
an image that represents this objects. I've an object that extends from
JTree (and named TTree). I need change this picture to evit the word
"JTree" that appears in the default picture.
How I can do this?
Many Thanks.
|
|
|
Re: About the picture that VE draws in the editor. [message #26308 is a reply to message #26268] |
Thu, 18 March 2004 10:00  |
Eclipse User |
|
|
|
Hi David,
> When I drag and drop a visual object over a JFrame (for example), VE draws
> an image that represents this objects. I've an object that extends from
> JTree (and named TTree). I need change this picture to evit the word
> "JTree" that appears in the default picture.
> How I can do this?
The image is in fact the one created by Swing itself - the VE just renders the
live object. The code that does this is the default constructor for JTree
public JTree(){
this(getDefaultTreeModel());
}
protected static TreeModel getDefaultTreeModel() {
DefaultMutableTreeNode root = new
DefaultMutableTreeNode("JTree");
// etc...
return new DefaultTreeModel(root);
}
You could override with something along the lines of
public class TTree extends JTree {
public TTree(){
if(getModel() instanceof DefaultTreeModel){
DefaultTreeModel defaultTreeModel = (DefaultTreeModel)getModel();
if (defaultTreeModel.getRoot() instanceof DefaultMutableTreeNode){
((DefaultMutableTreeNode)defaultTreeModel.getRoot()).setUser Object( "TTree");
}
}
}
Best regards,
Joe Winchester
|
|
|
Re: About the picture that VE draws in the editor. [message #584797 is a reply to message #26268] |
Thu, 18 March 2004 10:00  |
Eclipse User |
|
|
|
Hi David,
> When I drag and drop a visual object over a JFrame (for example), VE draws
> an image that represents this objects. I've an object that extends from
> JTree (and named TTree). I need change this picture to evit the word
> "JTree" that appears in the default picture.
> How I can do this?
The image is in fact the one created by Swing itself - the VE just renders the
live object. The code that does this is the default constructor for JTree
public JTree(){
this(getDefaultTreeModel());
}
protected static TreeModel getDefaultTreeModel() {
DefaultMutableTreeNode root = new
DefaultMutableTreeNode("JTree");
// etc...
return new DefaultTreeModel(root);
}
You could override with something along the lines of
public class TTree extends JTree {
public TTree(){
if(getModel() instanceof DefaultTreeModel){
DefaultTreeModel defaultTreeModel = (DefaultTreeModel)getModel();
if (defaultTreeModel.getRoot() instanceof DefaultMutableTreeNode){
((DefaultMutableTreeNode)defaultTreeModel.getRoot()).setUser Object( "TTree");
}
}
}
Best regards,
Joe Winchester
|
|
|
Powered by
FUDForum. Page generated in 0.06284 seconds