Using Netbeans I have been working with a GUI app for two years now. The code is generated at first from Netbeans IDE when selecting Java Desktop Application Project.
For the project Spacer it generates SpacerApp and SpacerView and it looks like this :
SpacerView looks more or less like this :
And now the punchline: I have found that I have another frame floating about here.
When I do this with the SpacerView class then two frames are visible.
Seems odd to me that this setup suggested by Netbeans offers one frame to use as the main guy (from FrameView) but
there is another frame (from app.getMainFrame()) floating around unused.
Why are there two? Is one of them a leftover from previous designs and should be avoided??
Can I use either one, or is one on its way to deprecation??
then uncomment the 2 lines and see if there's a difference in what's printed out.
if there are multiple frames, you might be better off posting in the Netbeans.org forum.
Joined: Dec 27, 2002
Thanks for writing Michael, however what you have shown me doesn't really bring any light into the room.
This app the way it's written has two main frames, one accessible by getFrame() in the view class and the other accessible with app.getMainFrame().
I know that two frames will appear when I say app.getMainFrame().setVisible(true). The existance of these two frames is the heart of my question.
Question is, since this app.getMainFrame() JFrame object is totally useless, why does it exist at all? Would I be correct in doing this right off ? :
Joined: Jun 09, 2003
just had a bit more of a read (Netbeans code is hard to follow) and, in theory,
JFrame mainFrame = app.getMainFrame();
app.getMainFrame().setBounds(10, 10, 500, 500);
should be the same frame, unless somewhere in throwing around the references there's a 'new JFrame()'
create another project and strip everything but frame-specific stuff, and your code to have 2 frames showing.
make sure we can compile/run/observe i.e. no org.jdesktop... references.
it should end up something similar to this (probably a few more classes)
if you run the above, there's only a single frame showing - at the secondary size/location
(swap them around, so the larger/centered specs are secondary, and this is what will be visible)