amar senapati

Greenhorn
+ Follow
since Nov 16, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by amar senapati

hi all,
how can i use the progress bar to my screen when a background process is going on...
for example....
i am connecting with the database and retrieving the database tables and displaying in my screen but it takes time during database connection and retrieveing datas from the database...
so how can i use the progress bar....
with regards
amar
22 years ago

Originally posted by Seema Hanji:
Hi All ,
One column in my JTable is Boolean . But this column should show check box and be editable only in some rows .
I am using Renderer and Editor for this column. Following is the renderer .
<pre>
public class CheckBoxRenderer extends JCheckBox implements
TableCellRenderer {

/**
* Constructor
*/
public CheckBoxRenderer() {
}

public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
value = table.getValueAt(row, column);
if (value instanceof Boolean) {
this.setSelected(((Boolean)value).booleanValue());

this.setHorizontalAlignment(JCheckBox.CENTER);

if (isSelected) {
setForeground(table.getSelectionForeground());
setBackground(table.getSelectionBackground());
} else{
setForeground(table.getForeground());
setBackground(table.getBackground());
}
return this;
}

return new JLabel("");
}
}
</pre>
Setting editor & renderer as below....
<pre>
CheckBoxRenderer doneRenderer = new CheckBoxRenderer();
DefaultCellEditor doneEditor = new DefaultCellEditor(checkBox);
table.getColumn(COL_NAME).setCellRenderer(doneRenderer);
table.setDefaultEditor(Boolean.class, doneEditor);
</pre>
In the table model I have implemented
getColumnClass() method to return Boolean.class for this column.
and also implemented setValueAt() to store the value in local array , as getValueAt() gets from this array.
If I click the checkBox in the column , it is checked . When I click it next time , it doesn't uncheck the checkBox. I have put System.out in setValueAt() method, it shows setting correct value everytime I click checkBox , but renderer seems to recieve wrong value . First time , value recieved in renderer is "false" , but in successive clicks , renderer always recieves "true" .
Am I missing something ??
Please Help ....
Thanks in advance .
-SSH



--------------------------

hi,
u can use defaulttable model and work out with these codes...i think it will help u.

final DefaultTableModel dataModel2 = new DefaultTableModel(vecHeader2,0)
{
public Class getColumnClass(int col)
{
return getValueAt(0, col).getClass();
}
public boolean isCellEditable(int row,int col)
{
if(col==0)
return true;
return false;
}
};
jtabSelectedColumn = new JTable(dataModel2);
cheers
amar
22 years ago
i have problem during getting the primary key column name from the MSAcess database with the jdbcdriver using the method getPrimaryColumn() with the database metadata...
i am able to get the column names and everything regarding the columns and tables...
when i used this method the error shows that this driver is not compatible with the getPrimaaryColumn() method.
please help me
with regards
amar
hi,
how can i use the progress bar to my screen when a background process is going on...
for example....
i am connecting with the database and retrieving the database tables and displaying in my screen but it takes time during database connection and retrieveing datas from the database...
so how can i use the progress bar....
with regards
amar
22 years ago