Custom initialization code for components?
Hello all. Is there any way to define custom initialization code for components? I'd like to not use the default constructor for JTree since it populates the tree with garbage data, but I can't seem to get around the UI Designer re-assigning the variable. For example, if I have:
this behavior is overridden in the UI Designer's init method. It seems that I then have to manually remove the sample data from the tree node which is both inefficient and a pain in the ^$$. I'd like to be able to specify the initialization / constructor behavior for components that are added to my form. Is this possible? Thanks so much.
Please sign in to leave a comment.
Hello!
Please, see "Using swing components subclasses without palette" discussion.
We already discuss it...
"jeff" <no_reply@jetbrains.com> wrote in message
news:12010157.1075684277729.JavaMail.itn@is.intellij.net...
components? I'd like to not use the default constructor for JTree since
it populates the tree with garbage data, but I can't seem to get around the
UI Designer re-assigning the variable. For example, if I have:
>
>
that I then have to manually remove the sample data from the tree node which
is both inefficient and a pain in the ^$$. I'd like to be able to specify
the initialization / constructor behavior for components that are added to
my form. Is this possible? Thanks so much.
I've read that discussion which does not seem to provide a solution. Instead, it discusses two different possible solutions for fixing this problem. AFAIK, the UI-Designer's init method does not check for null and will always override the construction of an component object. What is the way around this? Thanks!
BTW - when I say possible solutions, I mean possible solutions from the JetBrains team, not things that we as users can do.
Doesn anyone from JetBrains have any comments on this? It's ridiculous that there's no easy way to define the constructor for an object. The default constructor is the only one that's used which prevents using constructors that take data or easily using a subclass. If I'm developing a subclass of a component, I can't compile, add it to a custom palette, and restart IDEA every time I make a change. There's got to be an easier way to define custom initialization code. If possible, at least let the user specify a subclass in the UI-Designer. If I have a JTree form in my UI Designer I should be able to bind it to a subclass of JTree without having to add a custom palette.
I'm facing the same issue, so I'd like to bump this thread since no one from Jetbrains seems to have replied to it.
I'm a business logic/back-end developer trying to get a batter handle on GUI development by trying to use it. I was greatly encouraged by the IDEA GUI developer.
But, for some swing components its common to make a new subclass for each use (e.g. JTree). Unfortunately in the IDEA GUI editor this requires either creating a custom XML descriptor or clearing out the base class default nodes. Neither is a particullarly good situation for these one-off instances.
Anyone from JetBrains care to comment? Is this fixed in 4.5?
Aaron Tavistock wrote:
Why make subclasses of Jtree? Surely you'd just use the standard JTree
but provide a custom TreeModel object?
As for editing the XML - you can now edit the component pallette from
the UI Designer settings under your project configs.
--
Discouragement is a dissatisfaction with the past, a distaste for the
present, and a distrust of the future - Maree De Jong, CLCA.
Mark Derricutt --- mark@ talios.com --- http://www.talios.com
I think you have the right code, but are putting it in the wrong place. Here is what worked for me:
Hope this helps.
I think you have the right code, but are putting it in the wrong place. Here is what worked for me:
Hope this helps.
[sorry for the double post. I originally clicked the wrong hyperlink, and there does not appear to be an option for deleting a post]