# Yet another Java programming question

**URL:** <https://boards.straightdope.com/t/yet-another-java-programming-question/390536>\
**Category:** Factual Questions\
**Created:** [February 2, 2007, 2:02pm UTC](https://boards.straightdope.com/t/yet-another-java-programming-question/390536 "2007-02-02T14:02:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VunderBob](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@VunderBob](https://boards.straightdope.com/u/VunderBob)\
**Post date:** [February 2, 2007, 2:02pm UTC](https://boards.straightdope.com/t/yet-another-java-programming-question/390536/1 "2007-02-02T14:02:10Z")

</div>

I have yet another stoooopid Java programming question.

I’ve been attributing my problems to date on my unfamiliarity with build procedures and XML scripts. I’ve been developing with NetBeans, and if I hit the Build option on the menu, everything would compile and so on, but no dialog would open up when I tried to run or debug. To do what I wanted, I’d have to select the main dialog directly and run or debug it.

Well, yesterday it finally struck me what was really going on. I’ve been working in the MainFrame and dependent files, and paid 0 attention to Main. It is a placeholder, and had no code in it. **DOH!** :smack: I have to admit to being spoiled by Visual Studio, which will provide a simple Main with enough functionality to open the equivalent of the MainFrame class.

I’ve spent a couple of hours now looking for a Java tutorial that uses a simple GUI as an example of what I need to do to open up my dialog. Anyone out there able to point me in the right direction, either by example, or telling me directly what I need to do?

---

<div class="post-metadata">

**Author:** ![VunderBob](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@VunderBob](https://boards.straightdope.com/u/VunderBob)\
**Post date:** [February 2, 2007, 2:15pm UTC](https://boards.straightdope.com/t/yet-another-java-programming-question/390536/2 "2007-02-02T14:15:57Z")

</div>

Bump.

Found an example that I’m going to try. Stand by…

---

<div class="post-metadata">

**Author:** ![c\_goat](https://avatars.discourse-cdn.com/v4/letter/c/f4b2a3/32.png) [@c\_goat](https://boards.straightdope.com/u/c_goat)\
**Post date:** [February 2, 2007, 2:16pm UTC](https://boards.straightdope.com/t/yet-another-java-programming-question/390536/3 "2007-02-02T14:16:58Z")

</div>

I’ve never used netbeans, but usually all you need to get a window (JFrame) visible is:

MainFrame f = new MainFrame();  
f.pack(); // This sizes the window based on the layout/children  
f.setVisible(true);

The assumption here is that the constructor creates all the GUI elements (normally what I do). Otherwise you may need to stick a call to create() or something else before pack().

---

<div class="post-metadata">

**Author:** ![VunderBob](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@VunderBob](https://boards.straightdope.com/u/VunderBob)\
**Post date:** [February 2, 2007, 2:54pm UTC](https://boards.straightdope.com/t/yet-another-java-programming-question/390536/4 "2007-02-02T14:54:50Z")

</div>

w00t! It finally works!

**c\_goat** , I had to ad the SetVisible from your reply to the example I had to get everything working. A big thanks to you.
