This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 106283 - Matisse does not handle custom jPanel childrens properly
Summary: Matisse does not handle custom jPanel childrens properly
Status: RESOLVED INVALID
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-11 15:35 UTC by alexroat
Modified: 2007-07-03 16:58 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample code of the Bug (10.27 KB, application/x-gzip)
2007-06-26 22:44 UTC, alexroat
Details
SORY IS THIS ONE --> Sample code of the Bug (11.05 KB, application/x-gzip)
2007-06-26 22:59 UTC, alexroat
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alexroat 2007-06-11 15:35:35 UTC
Bug replication instruction :
*Create a new general java application.
*Add a new JFrame (call the class MyFrame) to the project and draw on it some
controls plus a Jpanel that would be refered by the variable jPanel1.
*Add a new JPanel (call the class MyPanel) to the project and draw on it some
other controls.
*I'd like to put the custom MyPanel in place of a common JPanel referring it by
the jPanel1 variable and also without install it in the palette, in manner to
leave all the code in a single project. So, I select jPanel1 from MyFrame and go
to the code tab. I click on Custom Creation Code and add "new MyPanel();" string
(without "").
*build and run the project.
*I expect to see the MyFrame with MyPanel placed into it at the place of jPanel1
but is possible to see only a common JPanel without the designed childrens.
*jPanel1 answer to callback defined in MyPanel class and I can print a list of
childrens to system.out correctly, but it's impossible to see the children as
they were not painted.
Trying to override the paint(...) method and forcing the children painting I
cannot get any results.
Comment 1 ehucka 2007-06-19 09:37:20 UTC
Could you provide more information about ide build, jdk, os? thanks
Comment 2 alexroat 2007-06-19 09:49:23 UTC
Of course,
I'm using Netbeans 5.5.1 for linux (installer binary netbeans-5_5_1-linux.bin ) on a ubuntu linux 7.04 Feisty Fawn.
The Jdk istalled is Java6 (I've got java-6-sun  and java-6-sun-1.6.0.00 subdirs in /usr/lib/jvm).

Many thanks.
Comment 3 Tomas Pavek 2007-06-22 17:45:47 UTC
Sorry, but I don't quite understand what the problem is. You don't see what you expect when you run the form, or only in
the design? Is the generated code in initComponents method correct? Could you possibly attach the project here?
Comment 4 alexroat 2007-06-26 22:44:30 UTC
Created attachment 44433 [details]
Sample code of the Bug
Comment 5 alexroat 2007-06-26 22:59:33 UTC
Created attachment 44435 [details]
SORY IS THIS ONE --> Sample code of the Bug
Comment 6 alexroat 2007-06-26 23:14:04 UTC
Hi,
sorry but I was away for a short vacation :-)
Ok, I've compressed the example in this tar.gz archive that contains the project folder, put it in your your NB
workspace and import it.
As you can see I've added a new Jpanel derived class called MyPanel (matisse based) in the main package and the main
frame MyFrame aside the startup class Main.
I've drawed a simple jlabel and jbutton into MyPanel using matisse editor.
In the MyFrame I've putted a JButton istance jButton1 and a JPanel instance jPanel1 using Matisse Editor.
I've then changed the jPanel1 construction code in the tabs of right side of Matisse Designer putting "new MyPanel();"
in the Custom Creation Code field.
Building and launching the application you can only see a naked JPanel without childrens.
Why ?
I need to substitute the common JPanel instance with a MyPanel instance referred by jPanel1 variable, otherwise what's
is usefull for the possibility to edit a JPanel derived class by Matisse editor ?


PS: sorry for the confusion in the attachments, the right one is the latest, watch the attachments description and
please ignore the other one.

Please let me know if there's still something unclear.

Regards

Alex
Comment 7 Tomas Pavek 2007-07-03 16:58:37 UTC
I see now. The problem is that jPanel1 in MyFrame has a layout code generated (GroupLayout) - setting layout causes the
components are removed. The GUI builder unfortunately does not know there is a different container with its own layout
since it is specified only via custom code and not really instantiated in the GUI form. However you can fix this easily
- just set the layout of the jPanel1 in MyFrame to Flowlayout. This is default layout of JPanel, so the GUI builder will
not generate any layout code and your custom panel will be left intact.

As for avoiding installation to palette - in NB 6.0 you can just drag MyPanel from project explorer onto the target
form. Even in 5.5.1 you should be able to do copy the file from explorer and paste it in the form (MyFrame node in
Inspector). Note you need MyPanel compiled for this.

So this is a bit confusing, but actually not a bug. We can't base the layout code generation on whether there is a
custom creation code or not. So I will close this issue.