BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Designer Fails for Unknown Reason

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder IDE
View previous topic :: View next topic  
Author Message
P. Michael Hutchins
Guest





PostPosted: Thu Feb 02, 2006 1:41 am    Post subject: Designer Fails for Unknown Reason Reply with quote



My class has the requisite:

public JcsPublisherGUI() {
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}

(where:
public class JcsPublisherGUI
extends JFrame implements DocumentListener {
)

when I go into the designer, I get a red block that seems to be complaining about the top-level class..
...but the Messages I get are useless..
...eg:
Problems encountered while processing the source code. Please check for possible syntax errors or uninitialized fields and variables.
Failed to create live visual subcomponent this as . Creating a red component in its place
....
...and..
Failed to create live visual subcomponent publishJButton as JButton publishJButton = new JButton();. Creating using default constructor javax.swing.JButton
(I mean what could possibly be the default constructor except for the one it's saying I'm using?)


Thanks in advance,

-- M.
Back to top
Lori M Olson [TeamB]
Guest





PostPosted: Thu Feb 02, 2006 3:45 am    Post subject: Re: Designer Fails for Unknown Reason Reply with quote



P. Michael Hutchins wrote:

Quote:
Problems encountered while processing the source code. Please check for possible syntax errors or uninitialized fields and variables.
Failed to create live visual subcomponent this as . Creating a red component in its place

I'd love to catch the person who changed this error message, and then
failed to change the documentation to go with it.

Instead of "red component", search for "red bean" in the JBuilder help
file. This topic is covered in detail.

--

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Back to top
P.Michael Hutchins
Guest





PostPosted: Thu Feb 02, 2006 7:51 pm    Post subject: Re: Designer Fails for Unknown Reason Reply with quote



"Lori M Olson [TeamB]" <javadragon (AT) techie (DOT) com> wrote:
Quote:
P. Michael Hutchins wrote:

Problems encountered while processing the source code. Please check for possible syntax errors or uninitialized fields and variables.
Failed to create live visual subcomponent this as . Creating a red component in its place

I'd love to catch the person who changed this error message, and then
failed to change the documentation to go with it.

Instead of "red component", search for "red bean" in the JBuilder help
file. This topic is covered in detail.

--

Regards,

Lori Olson [TeamB]


Thank you, Lori.

(BTW, is this the only way to get "support" on the ridiculous shortcomings that Borland continues to allow in their product - other than opening a~n incident~ for each such (requiring a maintenance contract, so *we* pay for their faults)?)

I followed your advice.

Turns out I had done all that researching before I posted this.

The only thing I found was the following:

-----------------
If JBuilder can't create an instance of a component for the designer, the component appears as a red box with its class name at the top. This is called a red bean. Red beans appear when: The class, or its constructor, is not public. The class threw exceptions on every constructor JBuilder tried. The class is the this object and extends an abstract class. Fix the first two issues by supplying a public default constructor. The third issue is more complex. When JBuilder needs to instantiate an object to be the this object, it can't instantiate the object you're designing. To circumvent this problem, JBuilder instantiates the superclass of the this object. If the superclass is abstract, it can't be instantiated. It's necessary to provide a concrete (non-abstract) proxy class. If this is what you need to do, please consult the Release Notes in the directory containing your JBuilder installation.
---------------------

ZERO of those things apply to my case.

Now what?

Is there some non-obvious reason why Borland can't manage to come up with actually useful error messages?
(not to mention documentation)


Thanks again,

-- M.
Back to top
Lori M Olson [TeamB]
Guest





PostPosted: Thu Feb 02, 2006 9:17 pm    Post subject: Re: Designer Fails for Unknown Reason Reply with quote

P.Michael Hutchins wrote:

Quote:
ZERO of those things apply to my case.

Now what?

Thanks again,

-- M.

I don't think I've ever seen a case where a red bean did not fall into
one of those categories. If you can post some example code that causes
this error, that might help.

--

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Back to top
Paul Furbacher [TeamB]
Guest





PostPosted: Thu Feb 02, 2006 9:53 pm    Post subject: Re: Designer Fails for Unknown Reason Reply with quote

Lori M Olson [TeamB] wrote:

Quote:
P.Michael Hutchins wrote:

ZERO of those things apply to my case.

Now what?

Thanks again,

-- M.

I don't think I've ever seen a case where a red bean did not fall into
one of those categories. If you can post some example code that causes
this error, that might help.

I have to agree with Lori, because you aren't telling us
the whole story. If I just mock up what you wrote in
your first message, i.e.,

Quote:
public class JcsPublisherGUI
extends JFrame implements DocumentListener {

public JcsPublisherGUI() {
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
// implemented methods omitted here for brevity

I get no "red bean" symptoms in JBuilder 2006. You must be
instantiating something in your code which has a constructor
which requires real parameters. Put the following around that
code if you can:

if ( ! Beans.isDesignTime() ) {
// offending code here
}

I just caught myself doing this just this morning with a
frame which was instantiating a helper object in the frame's
constructor. That help object required a single parameter
which ends up being the frame itself, as in

...
try {
jbInit();
if ( ! Beans.isDesignTime() ) {
helper = new MyHelper(this);
}
} catch (...) {...}
...

[That's a quick and dirty way of setting the helper
object into the frame. A better design would be to
inject it (i.e., "setHelper(MyHelper h)"). The injector
would be the application controller which is responsible
for instantiating the frame itself.]


If that's not it, look into the other suggested solutions
for the "red bean" symptom.


--


Paul Furbacher (TeamB)

Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
Back to top
P.Michael Hutchins
Guest





PostPosted: Thu Feb 02, 2006 10:06 pm    Post subject: Re: Designer Fails for Unknown Reason Reply with quote

First, THANK YOU! especially Paul's taking the trouble to give some more explanatory detail.
(I had never heard of anything like Beans.isDesignTime().)
(I don't use Beans (knowingly), so maybe that's one way in
which I'm missing out on the (implicit) background knowledge
required to use Designer, given that it doesn't bother to
tell you what's wrong.)

(I would appreciate a short response to this sub-issue.)


Now, ... I want to review a bit in order to explain what happened.

for ref., the info from JB Help:

--------------------
Handling red beans

If JBuilder can't create an instance of a component for the
designer, the component appears as a red box with its class name at the top.
This is called a red bean.

Red beans appear when:
o The class, or its constructor, is not public.
o The class threw exceptions on every constructor JBuilder
tried.
o The class is the this object and extends an abstract class.

Fix the first two issues by supplying a public default constructor.

The third issue is more complex.
When JBuilder needs to instantiate an object to be the this object, it can't instantiate the object you're designing.
To circumvent this problem, JBuilder instantiates the superclass of the this object.
If the superclass is abstract, it can't be instantiated.
It's necessary to provide a concrete (non-abstract) proxy class.
If this is what you need to do, please consult the Release Notes in the directory containing your JBuilder installation.
----------------------------

now...

I wasn't quite precise in my ZERO response..
...what *is* precise is the following:

The first item ("The class, or its constructor, is not public.") is not the case.

As for the second item, how in the world would I know, since JB doesn't bother to tell me?
(This is, IMHO, a serious shortcoming in JBuilder.)

The third item is not the case.

AND

The suggested fix ("Fix the first two issues by supplying a public default constructor.") does not work.


Only when I read through Paul's response did it dawn on me what's maybe going on.
:
Hypothesis:
What's implicit in the suggested fix is that there must be a
default constructor.
But what in fact is required is that JB must be able to
construct the object..
(& any other objects it requires)
..using *only* default constructors.

Do you see how these two things are very different?

So what the fix should say is that you have to go through all the code that's involved in creating your
object w/ the default constructor - looking for anything that uses other than the default constructor.

(and that's a pain in the butt; why in the world can't JBuilder tell us where it's having problems?)


If there's a better (read "higher productivity") way of finding the offender(s), PLEASE tell me!


And finally, Paul, it almost sounded like you were saying that using only default constructors is good
programming practice in general. Do you in fact assert that? I've never run across that point of view..
...and I have quite strong leanings in the opposite direction.


Thanks again,

-- M.
Back to top
Paul Furbacher [TeamB]
Guest





PostPosted: Thu Feb 02, 2006 11:55 pm    Post subject: Re: Designer Fails for Unknown Reason Reply with quote

P.Michael Hutchins wrote:

Quote:
First, THANK YOU! especially Paul's taking the trouble to give some
more explanatory detail. (I had never heard of anything like
Beans.isDesignTime().) (I don't use Beans (knowingly), so maybe
that's one way in which I'm missing out on the (implicit)
background knowledge required to use Designer, given that it
doesn't bother to tell you what's wrong.)

(I would appreciate a short response to this sub-issue.)

The Beans.isDesignTime() thing is something which Sun provided
for tool vendors so that visual designers could work. (It's
unfortunate that Sun forgot such commitments to tooling when
it wrote Swing!) So, yes, Beans.isDesignTime()is somewhat arcane
but it's not something JBuilder can tell you about in the IDE
itself. It would be helpful if the JBuilder Help provided
some comments on it in the chapter(s) on using the Designer.


Quote:
And finally, Paul, it almost sounded like you were saying that
using only default constructors is good programming practice in
general. Do you in fact assert that? I've never run across that
point of view.. ..and I have quite strong leanings in the opposite
direction.

There's an idea called "Inversion of Control" (IoC), or
"Dependency Injection" (Martin Fowler's preferred name
for IoC). The concept is that you should write your
objects such they are unconcerned with creating their
dependencies, such as JNDI contexts and lookups, and
so on. A number of IoC containers exist (Spring, Nanning,
Pico, Beehive, Hivemind, etc.), but dependency injection
doesn't necessarily require such a container. In simple
applications, you can have one object, say a controller,
which instantiates all objects and their dependencies,
as needed by events received by the controller.

Do I assert this to be the best practice? For decoupling
all your components and making them testable in isolation,
yes, I guess I'd have to say that it is a pretty sensible
practice. It provides better mocking capabilities, for one.
There are other issues, such as forcing your objects to
do just what they're supposed to do, without having to
be concerned about instantiating objects which they might
use, but don't necessarily have dominion over.


--


Paul Furbacher (TeamB)

Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
Back to top
P.Michael Hutchins
Guest





PostPosted: Fri Feb 03, 2006 2:29 am    Post subject: Re: Designer Fails for Unknown Reason Reply with quote

Thank you again, Paul.

I had hoped for a reply to my remaining core questions; let me [re]state them in their current state:


I:

The only possibility that I can see as remaining for why Designer failed, yielding a "red bean" is:

o The class threw exceptions on every constructor JBuilder
tried.

As I said, it's hard to know whether (or *when*) this is the case, given that JB apparently doesn't bother to tell me this.

Am I missing something?

- - - - - -
II:

The suggested fix ("Fix the first two issues by supplying a public default constructor.") does not work.


Only when I read through Paul's response did it dawn on me what's maybe going on.
:
Hypothesis:
What's implicit in the suggested fix is that there must be a
default constructor.
But what in fact is required is that JB must be able to
construct the object..
(& any other objects it requires)
..using *only* default constructors.

Do you see how these two things are very different?

So what the fix should say is that you have to go through all the code that's involved in creating your
object w/ the default constructor - looking for anything that uses other than the default constructor.

(II.a: Do you agree?)

(and that's a pain in the butt; why in the world can't JBuilder tell us where it's having problems?)


If there's a better (read "higher productivity") way of finding the offender(s), PLEASE tell me!

(II.b: If there's not, would you please tell me that that's what you think too.)

- - - - - -
III:

Using a fine-toothed comb, I did manage to find some things that - apparently - gave Designer indigestion.

....but I haven't managed to find what's bothering it about four objects; here's all the code that'sxz in JBinit() for one of them:
if (Beans.isDesignTime()) {
destinationJComboBox = new JComboBox();
} else {
destinationJComboBox = new JComboBox(JAGUAR_enums.components);
}
//
destinationTitledBorder = new TitledBorder(
BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)), "Destination");
destinationJComboBox.setEnabled(false);
destinationJComboBox.setBounds(new Rectangle(10, 22, 291, 24));

(For this guy, Designer sez:
Failed to create live visual subcomponent destinationJComboBox as JComboBox destinationJComboBox;. Creating using default constructor javax.swing.JComboBox
)

I don't understand why; do you?


Finally, I'm going to create a new thread to ask about whatever other Designer issues there are that leave me with a featureless gray rectangle with all my components seemingly (bec. invisibly) with random sizes and locations.
Back to top
Paul Furbacher [TeamB]
Guest





PostPosted: Fri Feb 03, 2006 9:36 pm    Post subject: Re: Designer Fails for Unknown Reason Reply with quote

P.Michael Hutchins wrote:

Quote:
I had hoped for a reply to my remaining core questions;

The reason I didn't attempt to answer the questions
is that they're so wordy that I cannot actually read
through them in short enough time.

Quote:
Am I missing something?

Don't know. You haven't provided the *complete*, but barebones
example to us which would speak more volumes than all this
hand wringing. One simple compilable example would be the
way to go from here on out. We could put it into JBuilder,
play with it and maybe tell you what's going on. Without
that, we're just flailing, and at the moment I'm pressed
for time to do diagnosing by guessing.


My only suggestion, in lieu of having a complete example
to work with, is that you either use the Beans.isDesignTime()
or put any initialization code which offends the Designer
in an override of the method "addNotify()". If you do
the latter, be sure to call "super.addNotify()" in the
first statement of that override. Forget to do that,
and you'll suffer.

I suspect your combobox issue is related to the enums-whatever
class you are trying to stuff into the constructor's arg list.
That's a candidate for putting in the "addNotify()" override.


--


Paul Furbacher (TeamB)

Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
Back to top
P.Michael Hutchins
Guest





PostPosted: Mon Feb 06, 2006 11:03 pm    Post subject: Re: Designer Fails for Unknown Reason Reply with quote

"Paul Furbacher [TeamB]" <pfurbacher (AT) mac (DOT) com> wrote:
Quote:
P.Michael Hutchins wrote:

I had hoped for a reply to my remaining core questions;

The reason I didn't attempt to answer the questions
is that they're so wordy that I cannot actually read
through them in short enough time.

Am I missing something?

Don't know. You haven't provided the *complete*, but barebones
example to us which would speak more volumes than all this
hand wringing. One simple compilable example would be the
way to go from here on out. We could put it into JBuilder,
play with it and maybe tell you what's going on. Without
that, we're just flailing, and at the moment I'm pressed
for time to do diagnosing by guessing.


My only suggestion, in lieu of having a complete example
to work with, is that you either use the Beans.isDesignTime()
or put any initialization code which offends the Designer
in an override of the method "addNotify()". If you do
the latter, be sure to call "super.addNotify()" in the
first statement of that override. Forget to do that,
and you'll suffer.

I suspect your combobox issue is related to the enums-whatever
class you are trying to stuff into the constructor's arg list.
That's a candidate for putting in the "addNotify()" override.


--


Paul Furbacher (TeamB)

Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.


Sorry for being verbose; I was trying to make the point that the documentation that says that Designer requires your class to have a default constructor - while necessary, is misleadingly far from sufficient: what it should say (should it not?) is that ALL constructors used in the code in JBinit() must be default.

Thanks again for your help.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder IDE All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.