Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011
    Posts
    3
    Rep Power
    0

    Default Unable to hide a JFrame

    I have a program which has to add menu's and stuff. for each "action" like adding a new menu, editing menu's, searching,... i let it open up a new frame for each.

    The problem is, that i can't seem to find how to let the action listener for the "cancel" button hide the frame it is put on. My main frame opens up the frame "MenuAdd" where there's textfield for name and stuff and the Ok and cancel button. The frame hides when I click on the X (default close operation) but i can't seem to make it work with and event when i click on the button cancel.. anybody have any idea how to make this work?

    Thanks

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

    Default

    Why use multiple JFrames? Why not use a dialog such as a JOptionPane or JDialog which could be a better fit?

    One way to make the top-level window invisible is to call setVisible(false) to a reference to this window. This reference may be obtained (among other ways) by using SwingUtilities.getWindowAncestor method.

  3. #3
    Join Date
    May 2011
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    Why use multiple JFrames? Why not use a dialog such as a JOptionPane or JDialog which could be a better fit?

    One way to make the top-level window invisible is to call setVisible(false) to a reference to this window. This reference may be obtained (among other ways) by using SwingUtilities.getWindowAncestor method.
    To import from a dropdown box?
    Or is that possible from JDialog or option pane as well?

  4. #4
    Join Date
    May 2011
    Posts
    3
    Rep Power
    0

    Default

    I found that working with multiple panels and showing/hiding them was the best answer :) and this solves my problem :) and for just basic input like only a name or something using JDialog/JOptionPanes :) and that using a CardLayout was also the best answer. Thanks for the quick response

Similar Threads

  1. How to Hide cursor
    By priya in forum Java Software
    Replies: 1
    Last Post: 12-09-2010, 09:39 PM
  2. Hide Application
    By Blackberrylerner in forum New To Java
    Replies: 1
    Last Post: 09-27-2010, 10:29 AM
  3. Replies: 1
    Last Post: 04-26-2010, 01:02 PM
  4. hide column
    By anilkumar_vist in forum Advanced Java
    Replies: 2
    Last Post: 12-13-2009, 05:46 PM
  5. Unable to display JDialog from JFrame
    By jv5 in forum NetBeans
    Replies: 2
    Last Post: 02-04-2009, 04:33 AM

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
  •