This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Graying out entire table.

 
Rio Reva
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having an option to gray out all the components in a panel, if the FTP service is not running.I am able to gray out all the components in the panel except the table in the panel.
I used setEnabled(false), for all these components, but doesn't seem to be working with table.Table still shows to be an active component.Can somebody help me so that I can give this table a grayed out look?
The table is put in a scroll pane, i am disabling scrollpane too.

Thanks in advance.
Reva.
 
Brian Cole
Author
Ranch Hand
Posts: 908
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rio Reva:
I used setEnabled(false), for all these components, but doesn't seem to be working with table.Table still shows to be an active component.Can somebody help me so that I can give this table a grayed out look?


The cell renderer that JTable uses by default doesn't pay attention
to whether the JTable is enabled or not. You can try something like


This should work if (1) you're using the default renderers, and
(2) the column type isn't Number/Date/Icon. If those don't hold,
you can do something similar but will have to make adaptations.

[edit: The column type list in (2) above should include Boolean.]
[ April 28, 2008: Message edited by: Brian Cole ]
 
Maneesh Godbole
Saloon Keeper
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rio Reva:
Hi,

I am having an option to gray out all the components in a panel, if the FTP service is not running.I am able to gray out all the components in the panel except the table in the panel.


Other than the solution mentioned by Brian, there is another way to do this. You can extend a JPanel, set it to be translucent, add listeners to trap mouse events, and the set it as the glass pane. I had taken this approach in one of my previous swing applications.

Of course, this can work only if you want to disable all the components in the existing frame (well not really, there is a work around, but your requirement doesn't seem to be that complicated)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic