Results 1 to 5 of 5
  1. #1
    captainpirate is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default How to Close ChildPanel only ??

    This is my MainFrame[JFrame] :



    when i click okButton then new panel called childPanel [Jpanel] is opened as like below:



    Then i click okbutton in childPanel, then showOptionDialog with ok option only is opened.




    Here is problem.
    I want to close childPanel only when i click ok button of optionDialog.
    Here is actionPerformed method of okButton of childPanel

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
    Object[ ] options = {"OK"};
    int pane = new JOptionPane().showOptionDialog(null, "Click ok to Continue", "OptionDialogFrame", JOptionPane.OK_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, null);
    if(pane==JOptionPane.OK_OPTION){
    //what code should i write here to close childPanel only

    }

    }

    Here is the Netbeans project : FrameApp.zip
    OS: Fedora 16
    IDE: Netbeans
    Help me !

  2. #2
    captainpirate is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default Re: How to Close ChildPanel only ??

    Sorry for the wrong place.
    Any one here to move it to Swing/AWT.

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: How to Close ChildPanel only ??

    moved

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,415
    Rep Power
    25

    Default Re: How to Close ChildPanel only ??

    What class is the childPanel? Does it have any methods that look like they will get rid of the window?

  5. #5
    captainpirate is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default Re: How to Close ChildPanel only ??

    Thanx for the concern guys !!
    I have solved it :

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
    Object[] options = {"OK"};
    int pane = new JOptionPane().showOptionDialog(null, "Click ok to Continue", "OptionDialogFrame", JOptionPane.OK_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, null);
    if (pane == JOptionPane.OK_OPTION || pane == JOptionPane.CLOSED_OPTION) {
    Window win = SwingUtilities.getWindowAncestor((Component) evt.getSource());
    win.dispose();
    }
    }

Similar Threads

  1. Purpose of close() ?
    By fatabass in forum New To Java
    Replies: 4
    Last Post: 01-13-2012, 09:57 AM
  2. Close a window
    By Johanis in forum New To Java
    Replies: 8
    Last Post: 10-27-2011, 06:05 PM
  3. Replies: 13
    Last Post: 04-09-2010, 11:15 AM
  4. Close JDialog
    By sky in forum AWT / Swing
    Replies: 7
    Last Post: 11-16-2009, 06:01 PM
  5. close to zero
    By nokicky in forum New To Java
    Replies: 6
    Last Post: 10-26-2009, 04:30 PM

Posting Permissions

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