Skip to main content



      Home
Home » Archived » Visual Editor (VE) » About the picture that VE draws in the editor.
About the picture that VE draws in the editor. [message #26268] Thu, 18 March 2004 03:00 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:About the picture that VE draws in the editor.
Next Topic:JSeparator
Goto Forum:
  


Current Time: Thu Jul 17 23:35:44 EDT 2025

Powered by FUDForum. Page generated in 0.06284 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top