JPanel layouts out of sync between Source & Design views

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

JPanel layouts out of sync between Source & Design views

Postby PaulW » Thu Nov 16, 2006 3:20 am

I have encountered problems in Version 6.0.0 when changing layouts on a JPanel. On the Properties page, the panels layout was set to FlowLayout. Then after review the layout was changed to GridBagLayout. When I view within Eclipse I see the screen as expected, but when I run the app I don't see the same layout.

After the sequence of editing described above (on the Properties page) along with other UI changes, the following code is produced (without the comments) that relates to the layout for the panel.

Code: Select all
final JPanel pnlBottom = new JPanel();
pnlBottom.setAlignmentX(Component.LEFT_ALIGNMENT);

// new layout appears here
pnlBottom.setLayout(new GridBagLayout());

// original layout appears here
final FlowLayout flowLayout_2 = new FlowLayout();
flowLayout_2.setAlignment(FlowLayout.LEFT);
flowLayout_2.setHgap(10);
pnlBottom.setLayout(flowLayout_2);


When the application is run, I see exactly what the code says, a FlowLayout, as it is applied last. However, within the development environment I see the panel laid out as GridBagLayout, which is what matches the properties page.

There appears to be a problem removing code associated with the previous layout.
Paul W
PaulW
 
Posts: 2
Joined: Thu Nov 16, 2006 2:42 am

Postby gnebling » Thu Nov 16, 2006 4:17 pm

I'm unable to reproduce this. Does it happen all the time? Can you outline step by step how to reproduce this behavior? Thanks
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Postby PaulW » Sun Nov 26, 2006 3:10 pm

I tried to reproduce the problem in a simple little class that extends JPanel but was unable to do so.

After analyzing the class in which I struck the problem, it was not very fair to expect the software to be able to understand what was going on.

The class appears to been based on a simple example that extended JFrame when first developed, and as development progressed, more and more code was added until the class now performs application initialisation as well as the manual instantiation of the main JFrame. To be fair the current application class needs to extract the GUI code into another class.

The more I look at the code in this class that needs to be refactored the more I am amazed that the product has done so well in understanding what it has.

Please disregard my original post.

Thanks
Paul W
PaulW
 
Posts: 2
Joined: Thu Nov 16, 2006 2:42 am

Postby Eric Clayberg » Thu Nov 30, 2006 1:35 pm

PaulW wrote:The more I look at the code in this class that needs to be refactored the more I am amazed that the product has done so well in understanding what it has.

Designer actually has a very powerful parser and tries its best to reverse engineer just about any code you throw at it regardless of source.

It can usually read and write code generated by other GUI builders without any problem. It also does pretty well with 80% of the hand written code out there.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest