Hello all,
I have an app that I'm building, slowly as I learn, and I'm having some issues with the JDialog implementation.

I'm using NetBeans which generates pretty much everything except for the gutsy bits of code needed... (i.e. code for button actions, etc)
I have my main application which uses a JFrame. I have created a menu using the JMenu items, so basically it's all Swing components so far.
I wanted to add a JDialog pop-up window when the user clicks Help->About in the main JFrame window. I have generated the code for the event listeners and all of that. I've even generated the JDialog swing component, again using NetBeans auto content. I've populated my JDialog with a little bit of text and viola, Insta-JDialog.

However, I'm having some issues calling it from the main JFrame. I've gone through the tutorials/examples on the Sun site, which are mediocre at best. Yes they show oodles of ways to use the different Dialog options and buttons, but don't actually show how to implement a JDialog Swing component from a pre-existing JFrame swing application.

I've found this thread: http://www.daniweb.com/forums/thread138875.html which gives a pretty good example, but I'm not certain exactly where to place the code. I've been comparing the code in that thread to the code generated by NetBeans, and I can sort of see where it is possible to place it, but it doesn't make sense that NetBeans would require me to write all of that when everything else in NetBeans is simple 'click & generate' style of adding things.
No I'm not just looking for the easiest way out of this, I'm truly perplexed by where to place anything. Comparing handwritten examples with pre-generated examples always proves difficult. (Yes, a drawback of using a full IDE, but non-the-less...)

At any rate, here is what I've got so far:

public class MainMenu extends javax.swing.JFrame {

    /** Creates new form MainMenu */
    public MainMenu() {
        initComponents();
    }
...
...
// inside here lies all the code generated for the JFrame Menu and it's Listeners
...
...
private void DataPortviewChkBox(java.awt.event.ItemEvent evt) {                                    
       // use CheckBox to open DataPortview JFrame window
       Object source = evt.getItemSelectable();
       if (DataPortviewChkBox.isSelected())
          frame4.setVisible(true);
       else
          frame4.setVisible(false);
    }
...
private void AboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                              
       // TODO add your handling code here:
    }                                             

    private void HelpMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                             
       // TODO add your handling code here:
    }
...
public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainMenu().setVisible(true);
            }
        });
    }

As you can see, I've already got pretty much everything laid out. And as I said before, the JDialog has already been created via NetBeans SwingWindow options.
I though I'd be able to call the JDialog using the same method that I used to call the additional JFrame with the CheckBox function above (lines 12-19), but I was obviously wrong.

So, given all of this, am I actually to write out the Dialog contents as specified in the link to the thread above? And if so, I'm assuming that is to be dropped into the main JFrame file, but again I'm not certain where. I've tried to put it just prior to the action event for the About button (line 20), but that didn't seem to work either.

Any insight would be greatly appreciated.
Thanks.

Ok,
well I found this: http://wiki.netbeans.org/SDIAppNetBeans
which is a really good and really straight forward short tutorial on how to implement JDialogs. Much better than the tutorials listed on the Sun site.
Although the ones on the Sun site show you all sorts of various options regarding the changes you can make to a Dialog, they don't really show you any implementation other than a one line snippet that obviously won't work if you are using Swing applications... unless I've completely missed it on the page.

Anyway, I'm marking this one Solved for my sake. Hope it can help others.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.