Results 1 to 4 of 4
  1. #1
    saeed144 is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default closing form and giving focus to all parents?

    Dear Helper,

    Say there is a Java application running, which has some multiple forms and the form is active and have focus,
    some other windows app. (notepad) is also maximized,

    While closing a form D which is a child of E (that is a child of F),
    Form E becomes active and gets the focus

    But, the notepad comes before the form E
    As I want form F appear right before form E,

    The code while closing form D is as follows:
    Java Code:
    if (parent != null){
                 parent.setEnabled(true);
                 parent.requestFocus();
             }
    Please help me debug,
    Thanks,
    Saeed144

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

    Default

    requestFocus isn't for setting focus on root containers such as Windows / JFrames /JDialogs, I believe, but rather is to set the focus on a widget within a root container if that root container has the focus. Question: what type of "forms" are you using? Are any JDialogs? Have you tried doing this using JDialogs?

  3. #3
    saeed144 is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default

    A little correction of hierarchy of classes

    public class d_frame extends e_frame {
    private e_frame parent;

    public class f_frame extends e_frame{
    public e_frame parent;

    public class j_frame extends e_frame{

    public class e_frame extends JFrame {
    a button in f_frame opens d_frame.
    when closing d_frame, the e_frame does not appear under f_frame(which is become activated and gets the focus)
    Notepad or any other application that is disabled comes over j_frame.

    In short, how can I make all forms of the application stick together so no other-than-application's-from appear in between them?

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

    Default

    I would use only one class that ultimately derives from JFrame. All the other "windows" should be JDialogs. Try this and let us know what happens.

    Incidentally, very few of my GUI classes subclass JFrame, JDialog, or any other root container. Most either subclass JPanel or more frequently, subclass nothing but are used to produce a JPanel, of which can be placed in any type of root container that I desire.

Similar Threads

  1. Giving Warning
    By tanmoy.b81 in forum New To Java
    Replies: 1
    Last Post: 12-24-2008, 10:21 AM
  2. Replies: 6
    Last Post: 11-28-2008, 07:55 AM
  3. [SOLVED] Construct parents using tree path.
    By Melki in forum AWT / Swing
    Replies: 2
    Last Post: 09-23-2008, 05:54 PM
  4. Giving Change: A Rudimentary Program (Questions)
    By carlodelmundo in forum New To Java
    Replies: 8
    Last Post: 08-14-2008, 12:33 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
  •