Results 1 to 7 of 7
  1. #1
    Grom is offline Member
    Join Date
    Aug 2008
    Posts
    20
    Rep Power
    0

    Default My first post, how to open 2nd window?

    Hello forum,

    I hope this is the right place to ask this, otherwise, well, sorry admin...

    My first post here!
    NetBeans on ubuntu
    Fresh in Java, I have little experiance with C#.
    How do I open a new window (form2) from main form?
    A code example would be greatest (where to paste it...)

    Kind regards, Grom

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Use the same code you used to create the first window to create the second one. Change the names to make them unique.
    Write a small program that creates a window. Then add to that program the code to create another one.
    Come back when you have problems.
    There are many examples of code on how to create a window. Search for JFrame

  3. #3
    HandyGeek is offline Member
    Join Date
    Feb 2008
    Location
    South Jordan, Utah, USA
    Posts
    5
    Rep Power
    0

    Default

    Hello Grom,
    If you are working on a Web-App, try the Visual JSP features of NetBeans. Also check out netbeans.org/kb/index.html - for the NetBeans tutorials .. an excellent place for beginners to start!

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    How do you want to open the second form on the first one? As a separate window(may be on an event) or as an internal one?

  5. #5
    Grom is offline Member
    Join Date
    Aug 2008
    Posts
    20
    Rep Power
    0

    Default

    Hello and thank you for your replays!

    Ok, I forgot to mention that I am making Desktop application.
    jFrame got me started.

    I have three calculators. Each one are opened in a new window from main window. In other words I have one main window, and from it
    - I can open three different calculators (as many as I like),
    - calculate and
    - close 'calculator' window..
    Saved calculations are being displayed in main window.

    I got this far; On main window I have a trigger that runs these lines:
    Form2 f2 = new Form2();
    f2.show();

    this opens new 'calculator window'.

    The problem is, as I try to close ANY of calculators windows, it is all being closed, even the main window.

    How can I avoid this?

    Kind regards, Grom

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    You don't show your code so this is only a quess.
    Check how you are handling the closing of JFrames. One of the options will exit the JVM. Some of them will only dispose of the window, some will ignore the close.
    Read the API doc for JFrame and look at the methods beginning with set....

  7. #7
    Grom is offline Member
    Join Date
    Aug 2008
    Posts
    20
    Rep Power
    0

    Default

    Hello all,

    Done. I set dispose option and it works fine. 10x Norm
    You can download my code here: www dot beezgetz dot com/NetBeans/TakeOne.zip and see how I did it.

    Thanks, Grom

Similar Threads

  1. First post ever
    By pbpersson in forum Introductions
    Replies: 4
    Last Post: 08-16-2008, 05:30 AM
  2. First post as per request
    By happyknappy in forum Introductions
    Replies: 3
    Last Post: 07-30-2008, 01:33 AM
  3. How to close an open JFrame window from a jsp page?
    By kasisaiganesh in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-27-2008, 06:29 PM
  4. Drive letter sniff/open explorer window
    By iiz in forum New To Java
    Replies: 1
    Last Post: 04-04-2008, 03:50 AM

Posting Permissions

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