dcsimg
Selective focus of cells in table
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anuradha_Saravanamuthu
Posted On:   Tuesday, January 29, 2002 11:22 PM

Hi all,
I am having a table of 4 columns. While tabbing through, i want the columns 3,4 are to be selected and not the 1,2. How to do that?

Right now, i put the code in isCellEditable() method


but 1,2 column gets focus then transfer happens. Any solution for avoiding the 1,2 column tab movement.

S.A.Radha.

thanx in advance.


S.A.Radha.

Re: Selective focus of cells in table

Posted By:   Anonymous  
Posted On:   Friday, February 1, 2002 05:10 AM

You can create a renderer for your table, that returns a JLabel component that is disabled for the concerned columns.
Ex for disable selection when value is null :

public Component getTableCellRendererComponent(JTable table,

Object value,

boolean isSelected,

boolean hasFocus,

int row,

int column) {




JLabel requestedComponent;


if (value==null || value.equals(null) || value.equals("")) {

requestedComponent = new JLabel();

requestedComponent.setEnabled(false);

}
else {

requestedComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

requestedComponent.setHorizontalAlignment(JLabel.CENTER);

}
return requestedComponent;

}
About | Sitemap | Contact