Results 1 to 4 of 4
  1. #1
    StevieM is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Cannot get NetBeans GUI to display

    Hi,

    I've been using the NetBeans GUI editor to make a little window, which I want to appear when a user clicks on the help menu of my Sudoku solver.

    I made my main Sudoku solver GUI based on a JFrame manually (without using NetBeans gui editor) and everything in that works fine. The mouse click event in this is definitely picked up ok….

    // code from mouse click event in Sudoku class.

    if (event.getSource() == gui.aboutSS) {

    // code flow definitely gets here when help item is clicked.

    // MyHelp is the JFrame based class created in NetBeans
    MyHelp help = new MyHelp();

    //Any idea why help doesn't appear?

    }


    I just can't get anything I make with the NetBeans gui editor to appear when instantiated from another class. I've tried JFrames / JDialogs / JPanels. They all work fine when I Design Preview them in editor.

    I'm obviously missing something really basic here. Huge thanks in advance to anyone who can help.

    Steve.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Cannot get NetBeans GUI to display

    Perhaps you need to make the MyHelp object visible via:
    Java Code:
    if (event.getSource() == gui.aboutSS) {
        MyHelp help = new MyHelp();
        help.setVisible(true);
    }
    Incidentally, your main JFrame should probably not launch another JFrame but rather a JDialog. Also, i commend you for creating the main GUI by hand and not via NetBean's code generation. I recommend that you avoid using NetBean's code generation until you understand Swing a bit better. You won't regret doing this.

  3. #3
    StevieM is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Re: Cannot get NetBeans GUI to display

    Thanks Fubarable for taking time to respond to my query. It's much appreciated.

    You are quite right, of course: "help.setVisible(true)" was all that was required. I thought that it wasn't needed because I saw it in the code that NetBeans generated for the window I'd made. On closer inspection this "setVisible" is in a main method, which NetBeans had created...but not in the constructor.

    I think that's where I'd been going wrong. This main method doesn't get called when I create my help object, so it was never being made visible.

    JDialog is exactly what I need too. I'm going to take your advice and read up on Swing more.

    Cheers,

    Steve.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Cannot get NetBeans GUI to display

    You're welcome and glad you've got things working!

Similar Threads

  1. Netbeans output window won't display
    By jujubinaj in forum New To Java
    Replies: 1
    Last Post: 12-16-2010, 03:51 AM
  2. Replies: 1
    Last Post: 12-01-2010, 07:35 PM
  3. Replies: 1
    Last Post: 05-31-2010, 09:46 AM
  4. Replies: 8
    Last Post: 12-29-2008, 08:12 AM
  5. Problem with display in Netbeans 5.5
    By Albert in forum NetBeans
    Replies: 1
    Last Post: 07-13-2007, 04:33 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •