Bug 46142 - Window inheritance size problems with subclass of subclass
Summary: Window inheritance size problems with subclass of subclass
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: VE (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: VE Bugzilla inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-05 16:59 EST by Joe Winchester CLA
Modified: 2011-06-13 11:37 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Winchester CLA 2003-11-05 16:59:11 EST
MyJFrame extends javax.swing.JFrame
set its size, title and background color.
MyJFrame2 extends MyJFrame.
In the Visual Editor the GUI for the JFrame does not show the inherited size.  
It shows the title and color OK so the initialize() is being called, however 
there is some code that is overriding the real size and making it a default no-
size window
Comment 1 Peter Walker CLA 2003-11-12 12:24:00 EST
Although this is not exactly what you would expect to see, this is WAD.

The reason for this is that when you drop a component onto the canvas (or in 
this case instanciate 'this' which is the superclass), if the size property is 
explicitly set (in this case MyJFrame2) the component's size is set based on 
it's preferredSize. This is applicable for other components as well. If you 
drop a JPanel or your own JPanel subclassed from a JPanel, the preferredSize is 
used, not size. 

Unfortunately, the preferredSize for a JFrame cannot be explicity set (in this 
case for MyJFrame) because it is a read only property so that inherited classes 
could drop to the desired size. But this works for other JComponents such as 
JPanel since it's a read/write property. But JFrame's preferredSize is 
calculated under the covers. To test this out, select and change the 
preferredSize of MyJFrame's content pane (a JPanel) to something like 300,200. 
Then open MyJFrame2 and it should resize to this setting.

I'd like to do propose a design change (which is why the severity of this 
defect is changed to "enhancement").
If you drop a component (or in this case instanciate the super class) on the 
canvas, if the size property is not explicitly set locally (in this case 
MyJFrame2), instead of setting the size to the preferredSize, check the size of 
the component in the VM and if it's not 0,0 then use whatever size is returned. 
Otherwise use the preferredSize (as is today).

Joe & Rich... please elaborate with more information if you need to.