🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
9 messages
9 total messages Started by Magnus Mon, 02 May 2005 13:13
Design window turning red
#410
Author: Magnus
Date: Mon, 02 May 2005 13:13
29 lines
2010 bytes
Hi,

I have developed a test program to work with JTree. I have a very simple 
gui-structure that looks like:

This
     contentPane(BorderLayout)
         statusBar
         jToolBar
         jSplitPane1
             currentSelectionField
             jScrollPane1
                 tree

All by a sudden, while swapping between Source and Design tabs - the 
design window turns red and I get the following message:

Failed to create live value from JPanel contentPane;: null
Failed to create live visual subcomponent contentPane (BorderLayout) as 
javax.swing.JPanel; creating a red component in its place
Failed to create live value from JTree tree;: null
Failed to create live visual subcomponent tree as javax.swing.JTree; 
creating a red component in its place

I have no idea what to change or even where to look for an error. The 
program runs fine and I have tried to alter the size, preferred and 
minimum size everywhere - but nothing works.

I'm running JBuilder 2005 Foundation
Re: Design window turning red
#411
Author: Paul Furbacher [TeamB]
Date: Mon, 02 May 2005 20:53
34 lines
2083 bytes
Magnus wrote:

> I have developed a test program to work with JTree. [...]
> 
> All by a sudden, while swapping between Source and Design tabs - the 
> design window turns red and I get the following message:
> 
> Failed to create live value from JPanel contentPane;: null
> Failed to create live visual subcomponent contentPane (Bord [...]

> I have no idea what to change or even where to look for an error. [...]

The <jbuilder install dir>/setup/release_notes.html file
is a good place to start; see the "Designer" section.

Also, this subject has come up often and is well
documented in the archives.  Try the keywords
"Failed to create live value" or "red bean".


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://www.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.
Re: Design window turning red
#444
Author: memyselfandI
Date: Tue, 24 May 2005 03:52
55 lines
2958 bytes
Ah Yes Indeed, the dreaded red beans issue.

The GUI designer is a very nice tool, but this read beans issue is one of the most often complained about issues in the newsgroups.

The big problem is that the designer does not produce intellegent error messages to help you determine what is occurring for you to correct.

What you can do to figure out wat is going on is: 
1.  comment out most of the initialization in jbinit
2.  comment all of your own methods
3.  launch the designer

At this point, unless something is very wacky, the designer should now work again.

Now, uncomment a bit at a time in the jbinit, each time go back to the designer.

If you get everything uncommented again in jbinit, then the issue is in one of your methods.  Un-comment each method, one at a time.

It is painful but doing this has always solved the problem for me.

"Paul Furbacher [TeamB]" <pfurbacher@mac.com> wrote:
>Magnus wrote:
>
>> I have developed a test program to work with JTree. [...]
>> 
>> All by a sudden, while swapping between Source and Design tabs - the 
>> design window turns red and I get the following message:
>> 
>> Failed to create live value from JPanel contentPane;: null
>> Failed to create live visual subcomponent contentPane (Bord [...]
>
>> I have no idea what to change or even where to look for an error. [...]
>
>The <jbuilder install dir>/setup/release_notes.html file
>is a good place to start; see the "Designer" section.
>
>Also, this subject has come up often and is well
>documented in the archives.  Try the keywords
>"Failed to create live value" or "red bean".
>
>
>-- 
>
>
>Paul Furbacher (TeamB)
>
>   Save time, search the archives:
>        http://www.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.
Re: Design window turning red
#448
Author: Magnus
Date: Tue, 24 May 2005 13:30
81 lines
4196 bytes
Thanks you!

I did have a problem with a customized tree that was built with values 
from a DB. I solved it with an "empty" constructor call in jbInit and 
then build the tree on another trigger. I also realized that if fields 
in jbInit are placed in proper order (i.e. red beans in the end) the 
rest of the fields are looking fine.

Now, after I fixed the tree-red bean, I ended up in another "issue". It 
is not a problem but is as follow:
- I have my custom tree in its own panel as part of a lot of other 
fields and graphs etc.
- My listener for the tree gives me what I need but to be able to update 
the fields outside the tree panel I have to make all of them static.
- Now I have all fields show up as red beans and all panels and 
everything is marked static.

Question: Is there a way to go from a static environment to a non-static 
environment. Can I place the tree-listener outside its own object and 
then trigger everything within the "main" panel.

memyselfandI wrote:

> Ah Yes Indeed, the dreaded red beans issue.
> 
> The GUI designer is a very nice tool, but this read beans issue is one of the most often complained about issues in the newsgroups.
> 
> The big problem is that the designer does not produce intellegent error messages to help you determine what is occurring for you to correct.
> 
> What you can do to figure out wat is going on is: 
> 1.  comment out most of the initialization in jbinit
> 2.  comment all of your own methods
> 3.  launch the designer
> 
> At this point, unless something is very wacky, the designer should now work again.
> 
> Now, uncomment a bit at a time in the jbinit, each time go back to the designer.
> 
> If you get everything uncommented again in jbinit, then the issue is in one of your methods.  Un-comment each method, one at a time.
> 
> It is painful but doing this has always solved the problem for me.
> 
> "Paul Furbacher [TeamB]" <pfurbacher@mac.com> wrote:
> 
>>Magnus wrote:
>>
>>
>>>I have developed a test program to work with JTree. [...]
>>>
>>>All by a sudden, while swapping between Source and Design tabs - the 
>>>design window turns red and I get the following message:
>>>
>>>Failed to create live value from JPanel contentPane;: null
>>>Failed to create live visual subcomponent contentPane (Bord [...]
>>
>>>I have no idea what to change or even where to look for an error. [...]
>>
>>The <jbuilder install dir>/setup/release_notes.html file
>>is a good place to start; see the "Designer" section.
>>
>>Also, this subject has come up often and is well
>>documented in the archives.  Try the keywords
>>"Failed to create live value" or "red bean".
>>
>>
>>-- 
>>
>>
>>Paul Furbacher (TeamB)
>>
>>  Save time, search the archives:
>>       http://www.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.
> 
> 
Re: Design window turning red
#514
Author: Paul Furbacher [TeamB]
Date: Sun, 29 May 2005 11:48
114 lines
6054 bytes
Magnus wrote:

> I did have a problem with a customized tree that was built with values 
> from a DB. 

Shouldn't be designed this way.  Your component should stand
on its own without data.  The classes that use it are the only
ones which should put data into it -- all it should know
how to do is to display the data other classes put into it.
It should not access databases; it should not read files; it
should just sit there like a lump until something else provides
data to it.

> I solved it with an "empty" constructor call in jbInit and 
> then build the tree on another trigger. I also realized that if fields 
> in jbInit are placed in proper order (i.e. red beans in the end) the 
> rest of the fields are looking fine.

That's not really the solution.  If your tree component is truly
designed with a default constructor and does not incorrectly try
to populate itself by accessing a database in that constructor,
you should have no red bean issues to deal with.  It is a view
component, not a model or controller component.

Did you create this custom tree component so that it accesses
a database?  If so, this is definitely the wrong way to go.
Tree = view.  I might even venture to say that all you may
need to do is to write a node class which implements a data-
specific "toString()" method.  Put your database access and
tree model building code in a business object class and simply
write

   MyBusinessObject mbo = new MyBusinessObject(...);
   // where "..." represents database config.
   TreeModel tm = mbo.getDataForParams(...);
   // where "..." represents selection params, etc.

   myStandardJTree.setModel(tm);


in a method other than "jbInit()".

I'm willing to bet that if you refactor your thinking
and design, my comments below will become irrelevant because
JTree already has all the events you need in order to
respond to selection changes, etc.  Again, the tree is
just a view; it should never be the one operating on your
model.

> Now, after I fixed the tree-red bean, I ended up in another "issue". It 
> is not a problem but is as follow:
> - I have my custom tree in its own panel as part of a lot of other 
> fields and graphs etc.
> - My listener for the tree gives me what I need but to be able to update 
> the fields outside the tree panel I have to make all of them static.

There is no reason why you need to define static member variables
of the frame or panel in which an instance of your custom
tree component resides.  How and where did you make the listener
class?  Is it an anonymous nested/inner class of the frame/panel
in which your custom tree resides?  Or did you create it
inside the custom tree's class?  (I suspect the answer is yes
to the latter.)

> - Now I have all fields show up as red beans and all panels and 
> everything is marked static.

With a properly designed event you should be able to plop
your custom tree into your panel/frame using the Designer,
flip to the events tab of the Property Inspector, double-click
on your custom event.  (Assuming you did implement the event;
if not, implement it in the JavaBeans way of doing this.  See
Sun's tutorials on events at their site.)  The Designer will
create the anonymous adapter; you code the details.  Since the
listener adapter is implemented in the frame in which the member
variables you want to access are declared, you have instance-based
access to them.  No need for statics anywhere.

> Question: Is there a way to go from a static environment to a non-static 
> environment. Can I place the tree-listener outside its own object and 
> then trigger everything within the "main" panel.

I think you should be able to answer this question with a bit
of "follow the example" learning: take an ordinary JTree
and ask, how do I provide a listener to one of its standard
events, e.g., a selection event?  Since JTree is already written,
you obviously don't dig into its class source code and add
listeners inside JTree.  Where do you implement the listener?
How should you do this using (focus on "using") your custom
component?  How should you design your custom component so
that other interested classes may register to receive
event notifications?

It may be a good idea to get a book on Swing and review
events, both from designing them into your components,
registering handlers with the components, and so on.  Or
at the very least, work through the events tutorials on
the java.sun site.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://www.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.
Re: Design window turning red
#520
Author: Magnus
Date: Mon, 30 May 2005 16:26
101 lines
4631 bytes
Superthanks for your input. Some of it I understand and some of it I don't.
I have followed multiple tutorials and and implemented to fit my need.

This is what I have:
An application where using a tree to display what is in the DB and used 
for selection (that then triggers actions). A tree is used in a couple 
of different screens. The tree is only to show values and enable easy 
navigation and selection.

My tree implementation:

public class MyTree extends JPanel  implements TreeSelectionListener {

   static final int USED_AT_A = 0; // where tree is implemented
   static final int USED_AT_B = 1;

   public MyTree(nodeInfo topNode,int type) {

   public void valueChanged(TreeSelectionEvent e) {
   // this then determine what type it is and use "a ststic method"
   // to set selected values. The method to used is determined by
   // USED_AT_A or USED_AT_B

   public String[] getSelEquip() {
   // used from mainFrame to get values

   public clear(nodeInfo top) {
   // clear the tree and start a new one with top as root

   public DefaultMutableTreeNode insertNode (
   // used from mainFrame to build the tree
   // (i.e. getting data from DB is outside the tree)

   public static class nodeInfo {
   // My different types of nodes
         public String id;
         public String ttype;
         public String what;

         public nodeInfo(String nID, String t, String w) {
             id = nID;
             ttype = t;
             what = w;
         }
         public String toString() { return id; }
         public String getType() { return ttype; }
         public String getWhat() { return what; }
     } // end nodeInfo

     private class MyRenderer extends DefaultTreeCellRenderer {
     // used to set cirrect Icons and tooltip depending on type

} // end MyTree

So i create in my panel where I want to work with my tree:

public class mainFrame extends JFrame {

  MyTree firstTree;

...

  firstTRee = new MyTree(new MyTree.nodeInfo(
                 "Empty","C", "C"), MyTree.USED_AT_A);

  //this creates my empty tree that can be seen in designer.

  buildTree(firstTree) { // a method to get DB from DB and to build tree.

Here is where I fail:
1) The listener is iplemented in MyTree (as I thought it should)
2) When a tree selection happens - the listener updates values in the 
panel where "firstTree" is implemented. The update use a method that
"must" be static since I can't create a
    mainFrame frame = new mainFrame();
within MyTree. (since I in frame have created firstTree) ...
3) Since method used by firstTree.<my static method> is static it 
ripples through all functions and GUI components that then will be 
updated by a selection in the tree.

So, where have I gone wrong ? How to fix this?

Thanks in advance,

Magnus

Paul Furbacher [TeamB] wrote:
> Magnus wrote:
> 
>> I did have a problem with a customized tree that was built with values 
>> from a DB. 
> 
> 
> Shouldn't be designed this way.  Your component should stand
> on its own without data.  The classes that use it are the only
> ones which should put data into it -- all it should know
> how to do is to display the data other classes put into it.
> It should not access databases; it should not read files; it
> should just sit there like a lump until something else provides
> data to it.
> 
Re: Design window turning red (now NullPointer)
#529
Author: Magnus
Date: Fri, 03 Jun 2005 14:29
28 lines
2194 bytes
I got rid of all read beans :)

Now I have a "java.lang.NullPointerException" :(

I have gone back to an older version without this problem and compared 
the constructors without any luck. I commented out 99.9% of the 
constructor and jbinit but still no luck.

The only message jBuilder2005 gives me is as above. No rows, or fields 
or methods or anything to work on.

Anyone who have any tips on how to find the problem? Can the problem be 
in the order of declarations?

Magnus wrote:

> Superthanks for your input. Some of it I understand and some of it I don't.
> I have followed multiple tutorials and and implemented to fit my need.
> 
> This is what I have:
> An application where using a tree to display what is in the DB and used 
> for selection (that then triggers actions). A tree is used in a couple 
> of different screens. The tree is only to show values and enable easy 
> navigation and selection.
> 
> My tree implementation:
> 
[cut]
Re: Design window turning red (now NullPointer)
#535
Author: Magnus
Date: Tue, 07 Jun 2005 03:39
44 lines
2619 bytes
I found my problem
I declared some Icons like:

ImageIcon redIcon, yellowIcon, greenIcon;

After some hours making a backup and deleting part after part it turned 
out the I have to declare it as:

     ImageIcon redIcon;
     ImageIcon yellowIcon;
     ImageIcon greenIcon;

The program worked but the designer was corrupt. Now I know!

Magnus wrote:
> I got rid of all read beans :)
> 
> Now I have a "java.lang.NullPointerException" :(
> 
> I have gone back to an older version without this problem and compared 
> the constructors without any luck. I commented out 99.9% of the 
> constructor and jbinit but still no luck.
> 
> The only message jBuilder2005 gives me is as above. No rows, or fields 
> or methods or anything to work on.
> 
> Anyone who have any tips on how to find the problem? Can the problem be 
> in the order of declarations?
> 
> Magnus wrote:
> 
>> Superthanks for your input. Some of it I understand and some of it I 
>> don't.
>> I have followed multiple tutorials and and implemented to fit my need.
>>
>> This is what I have:
>> An application where using a tree to display what is in the DB and 
>> used for selection (that then triggers actions). A tree is used in a 
>> couple of different screens. The tree is only to show values and 
>> enable easy navigation and selection.
>>
>> My tree implementation:
>>
> [cut]
Re: Design window turning red (now NullPointer)
#536
Author: Lori M Olson [TeamB]
Date: Tue, 07 Jun 2005 05:28
36 lines
2138 bytes
Magnus wrote:
> I found my problem
> I declared some Icons like:
> 
> ImageIcon redIcon, yellowIcon, greenIcon;
> 
> After some hours making a backup and deleting part after part it turned 
> out the I have to declare it as:
> 
>     ImageIcon redIcon;
>     ImageIcon yellowIcon;
>     ImageIcon greenIcon;
> 
> The program worked but the designer was corrupt. Now I know!
> 

<Jaw dropping open>.  That is so stupid.  Please post a bug about that.

-- 

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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads