• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Subject: Disabling a JPanel and all it's components

 
Ranch Hand
Posts: 164
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read the past by Gregg Bolinger
Tuesday, October 09, 2001 05:16 Subject: Disabling a JPanel and all it's components

and used the code however i have three jtextAreas on the panel that still remain active any ideas as to why that is and how to disable them as well
 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can retreive all the components from your panel with getComponents() (it returns all components as Component array). Iterate through array with a loop and disable each component.
JTextArea is a specific component in this case. Actually, when you have it on your panel, what you get is not the text area, but scroll pane (automatically added when you add text area). So what you should actually do is implement a recursive method, that can pick those components that are "deeper" (like the case here). Once you have them all (e.g. in a list), disable all of them.
 
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tell us why you want to disable everything,
as there may be a better approach.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I presume this is the old thread you mentioned. I haven’t read it. Did it discuss the enable() and disable() methods? You are not supposed to use them any more; use setEnabled(true) or setEnabled(false). It is worth going through the hierarchy of Swing components and finding how many have setEnabled() methods at all; I can’t remember where that method is declared.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic