CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2000
    Posts
    6

    Close Button Not Working

    How come sometimes the close buttons, the "x" on the top right corner on the forms aren't responding? I'm very sure the forms are working well coz I made a command button that closes the application. Any solution to this? Thanx


  2. #2

    Re: Close Button Not Working

    You have to be a component listener to the frame/dialog and use this

    public void componentClosed(ComponentEvent e)
    {
    hide();
    }


    keith

  3. #3
    Join Date
    Apr 1999
    Posts
    48

    Re: Close Button Not Working

    Or you may create your own frame class and use it instead of Frame. Do this:

    class MyFrame extends Frame
    {
    public boolean handleEvent(Event e) {
    if(e.id==Event.WINDOW_DESTROY) {
    dispose();
    }
    }
    }




    Good luck, ytsau



  4. #4
    Join Date
    Apr 1999
    Posts
    48

    Re: Close Button Not Working

    Or you may create your own frame class and use it instead of Frame. Do this:


    class MyApplet extends Applet
    {
    MyFrame frame;
    init()
    {
    frame = new MyFrame();
    frame.show();
    }
    public boolean action(Event e, Object o) {
    if(e.target==mybutton) {
    frame.dispose();
    }
    }

    class MyFrame extends Frame
    {
    public boolean handleEvent(Event e) {
    if(e.id==Event.WINDOW_DESTROY) {
    dispose();
    }
    }
    }



    The applet will create a new frame. It can be closed by clicking its [x], or you can click your button named mybutton to close it. Good luck, ytsau



Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured