Question on JPanel

Discussion in 'Java' started by Soundar, Jan 30, 2005.

  1. Soundar

    Soundar Guest

    If I set a JPanel to not enabled

    pane.setEnabled(false);

    I am still able to select the components that are the panel's children.
    Coming from a VB background, I find this strange. If you disable a
    panel, all its children should be automatically disabled. Am I doing
    something
    wrong? Do I have to disable each child one by one?
    -----------
    I am reposting this question since I did not get a response to a
    previous post of the same question...probably no one read it :)
     
    Soundar, Jan 30, 2005
    #1
    1. Advertising

  2. Soundar

    Ann Guest

    "Soundar" <> wrote in message
    news:...
    > If I set a JPanel to not enabled
    >
    > pane.setEnabled(false);
    >
    > I am still able to select the components that are the panel's children.
    > Coming from a VB background, I find this strange. If you disable a
    > panel, all its children should be automatically disabled. Am I doing
    > something
    > wrong? Do I have to disable each child one by one?


    Did you add them one by one? Don't you like to have a choice?
     
    Ann, Jan 30, 2005
    #2
    1. Advertising

  3. Soundar

    Guest

    You are corredt, the children of the panel are still enabled. In most
    cases this is a nuisance, however it does have its uses. For example,
    think about a tabbed or scroll-pane where you might want to prohibit
    the user from doing anything with the panel itself (scrolling, changing
    tabs etc), but still want him to be able to use the components on the
    pane.

    To reduce the work of disabling all the components one by one, you
    could put them into a Collection, and hand this collection off to a
    generic function that iterates through the collection and does
    often-needed stuff with each component.

    regards,
    Elmar
     
    , Jan 31, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott

    JPanel and Graphics

    Scott, Jul 2, 2003, in forum: Java
    Replies:
    0
    Views:
    2,327
    Scott
    Jul 2, 2003
  2. steve smith
    Replies:
    0
    Views:
    544
    steve smith
    Jul 10, 2003
  3. Andreas Beresko

    Add a JPanel to a JPanel...

    Andreas Beresko, Jul 14, 2004, in forum: Java
    Replies:
    6
    Views:
    27,036
  4. Raphael Jolivet

    [JPanel] Drop Down JPanel

    Raphael Jolivet, Jul 18, 2008, in forum: Java
    Replies:
    1
    Views:
    1,550
    John B. Matthews
    Jul 18, 2008
  5. t1m1976
    Replies:
    1
    Views:
    2,447
    t1m1976
    Nov 7, 2010
Loading...

Share This Page