Community
Participate
Working Groups
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
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.