Results 1 to 6 of 6

Thread: New Jframe java

  1. #1
    Join Date
    Jan 2007
    Beans
    Hidden!

    New Jframe java

    Hi i'm doing a GUI project in netbeans. And i have my main Jframe, any one know how i can get another one. Like when I press a button a new Jframe pops
    up.

  2. #2
    Join Date
    Oct 2007
    Beans
    1,914
    Distro
    Lubuntu 12.10 Quantal Quetzal

    Re: New Jframe java

    You can just instantiate any Frame and call the setVisible(true) method of it, just like it is done in the pre-generated main() method of a JFrame:
    PHP Code:
    new YourFrame().setVisible(true); 
    For making it open when you press a button, double click onto the "actionPerformed" event of the button and Netbeans will make a method (in the frame class) for you that is called when you press the button.

  3. #3
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: New Jframe java

    Ok thaks...just one more question. I see when i create a new Jframe its set up whit a main. Is it suppose to?

  4. #4
    Join Date
    Mar 2008
    Location
    Denmark
    Beans
    134
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: New Jframe java

    Depending on what you need it for it sounds like you might benefit from using a JDialog instead of a JFrame.

    I'm not sure what you mean by it's set up with a main?

  5. #5
    Join Date
    Oct 2007
    Beans
    1,914
    Distro
    Lubuntu 12.10 Quantal Quetzal

    Re: New Jframe java

    Quote Originally Posted by Geir102 View Post
    Ok thaks...just one more question. I see when i create a new Jframe its set up whit a main. Is it suppose to?
    Of course it is supposed to - otherwise Netbeans wouldn't do it. No, just kidding. The automatically included main(...)-function is just for convenience. It is good practice to delete it if it isn't needed.

  6. #6
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: New Jframe java

    thanks alott for the quick answers

Bookmarks

Posting Permissions

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