Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Loosing focus on entire column  RSS feed

 
Hlumela Bongobi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I have a column in my table that I have made invisible to the user(because i need the information in it but I don't want the user to see the information). The problem is that it still gains focus. I know this because I display just above the table the description(which I need to do) of the particular column.
I want this column to lose focus completely at once when I create the table.
Your help will be highly appreciated.
 
Brian Cole
Author
Ranch Hand
Posts: 935
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hlumela Bongobi:
I have a column in my table that I have made invisible to the user(because i need the information in it but I don't want the user to see the information). The problem is that it still gains focus.


Is the column 'invisible' in the sense of
tab.getColumnModel().removeColumn( tab.getColumnModel().getColumn(n) ) ?

Because if so, I don't see any way it could get focus. Perhaps you should explain in more detail what you are doing.
[ December 06, 2007: Message edited by: Brian Cole ]
 
Hlumela Bongobi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is how I am doing it:

TableColumn column = table.getColumnModel().getColumn(index);
SizeRequirements size = new SizeRequirements();
column.setMinWidth(size.minimum);
column.setMaxWidth(size.maximum);
column.setPreferredWidth(size.preferred);

The above code hides the column completely, but it still gains focus.
 
Brian Cole
Author
Ranch Hand
Posts: 935
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hlumela Bongobi:
This is how I am doing it:

TableColumn column = table.getColumnModel().getColumn(index);
SizeRequirements size = new SizeRequirements();
column.setMinWidth(size.minimum);
column.setMaxWidth(size.maximum);
column.setPreferredWidth(size.preferred);

The above code hides the column completely, but it still gains focus.


You realize, I hope, that this is the same as just doing:

TableColumn column = table.getColumnModel().getColumn(index);
column.setMinWidth(0);
column.setMaxWidth(0);
column.setPreferredWidth(0);

So the table treats the column as if it does exist, but it gets zero width.


Instead I recommend what I mentioned above:

TableColumn column = table.getColumnModel().getColumn(index);
table.getColumnModel().removeColumn( column );
 
Hlumela Bongobi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but I still need the information in the table it's just that I don't want the user to see the information.
I have tried the above code but it removes the column completely.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With this approach, you remove the column from the table. The table's model still has the column.
 
Hlumela Bongobi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh,I see! Thank you very much Brian and Rob.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!