• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GUI gives me two JFrames in Netbeans Desktop Application Template

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this change, see what prints out


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.

 
Dave Elwood
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ? :





 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just had a bit more of a read (Netbeans code is hard to follow) and, in theory,
JFrame mainFrame = app.getMainFrame();
and
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)


and

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)
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


that's heartening to hear. I kept thinking, 'there must be an easier way, this is nuts.'

I'll try out your suggestions as soon as possible.

Thanks muchly.
reply
    Bookmark Topic Watch Topic
  • New Topic