Results 1 to 4 of 4
  1. #1
    SarahB is offline Member
    Join Date
    Dec 2009
    Posts
    4
    Rep Power
    0

    Default Frame doesn't appear

    Hello,

    I'm trying to make a button that when pressed it shows another frame (CustomerOrder) and hides the current one.

    private void btnDoneActionPerformed(java.awt.event.ActionEvent evt) {
    this.setVisible(false);
    new CustomerOrder.setVisible(true);
    }

    It's not working, only the current frame hides and nothing happens.

    Any ideas what the problem could be ?

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

    Default

    This should cause a compiler error, right?:
    Java Code:
    new CustomerOrder.setVisible(true);
    Better perhaps is:
    Java Code:
    new CustomerOrder().setVisible(true);
    Having said this, I much prefer swapping JPanels via a CardLayout than swapping JFrames.

    BTW, welcome to the forum.

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    Good advice from F7e regarding CardLayout. As far as chaining method calls... Java obviously allows it, and it's not wrong, but it makes debugging your program more difficult. If adding the () to CustomerOrder fixed the problem, pls mark your post as solved.

  4. #4
    SarahB is offline Member
    Join Date
    Dec 2009
    Posts
    4
    Rep Power
    0

    Default

    Thank you so much "Fubarable" and "Steve11235" for your replies. It's now solved :)
    I

Similar Threads

  1. Replies: 7
    Last Post: 11-02-2009, 07:31 PM
  2. frame as an applet
    By shruti in forum Java Applets
    Replies: 0
    Last Post: 07-18-2009, 12:32 PM
  3. GUI new frame
    By billbo123 in forum New To Java
    Replies: 15
    Last Post: 03-02-2009, 05:24 AM
  4. frame
    By arunkumarinfo in forum NetBeans
    Replies: 0
    Last Post: 02-07-2009, 11:26 AM
  5. Frame to other Frame
    By Aswq in forum New To Java
    Replies: 2
    Last Post: 07-19-2008, 05:27 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
  •