Results 1 to 5 of 5
- 10-13-2010, 12:41 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 88
- Rep Power
- 0
Validating the jtable data on cell
I have a jtable in which contains 4 columns
1 max marks
2 min marks
3 secured marks
4 pass/fail
1 ,2,4 are not editable only secured marks is editable
on change of secured marks i want to validate marks
I implemented TableModelListener i am able to get row,column,value etc but it is throwing exception on setValueAt(x,r,4);
plz help....
-
Columns should go from 0 to 3 then, right?
A couple of problems:1 ,2,4 are not editable only secured marks is editable
on change of secured marks i want to validate marks
I implemented TableModelListener i am able to get row,column,value etc but it is throwing exception on setValueAt(x,r,4);
plz help....
1) You're trying to set column 4 when columns go from 0 to 3?
2) You've got an exception that you're not showing us
3) You've got a bug in code that you're not showing us..
How can you expect much help with the limited information you've provided?
- 10-13-2010, 01:18 PM #3
Member
- Join Date
- Oct 2009
- Posts
- 88
- Rep Power
- 0
This is my code and the text with red color that situation me exception
public void changeData(TableModelEvent e){
status=3;
try{
int row=e.getFirstRow();
if(e.getType()==TableModelEvent.UPDATE){
TableModel tm=(TableModel)e.getSource();
int secured = Integer.parseInt(tblMarks.getModel().getValueAt(ro w, 3).toString());
int marks = Integer.parseInt(tblMarks.getModel().getValueAt(ro w, 2).toString());
int maxMarks = Integer.parseInt(tblMarks.getModel().getValueAt(ro w, 1).toString());
if (secured >= marks) {
try{
tm.setValueAt("P",row,4);
}catch(Exception ex){}
}
else {
try{
tm.setValueAt("F",row,4);
}catch(Exception ex){}
}
tblMarks.setModel(tm);
}
}catch(Exception ex){
errMsg.setText("Invalid Number");
}
}Last edited by anilkumar_vist; 10-13-2010 at 01:22 PM.
- 10-13-2010, 01:31 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
What exception are you getting, with stack traces?
Of course if this is actually your code then you are eating exceptions so you won't be able to give us that info.
-
Code tags please
Exception text, please
Similar Threads
-
JTable Cell Merg
By anilkumar_vist in forum AWT / SwingReplies: 8Last Post: 04-25-2011, 09:32 AM -
Validating Jtable
By anilkumar_vist in forum Advanced JavaReplies: 1Last Post: 11-24-2009, 02:54 PM -
Jtable and cell coordinates
By rattaman in forum AWT / SwingReplies: 2Last Post: 11-17-2009, 05:48 PM -
jtable cell renderer
By ankitmcgill in forum New To JavaReplies: 2Last Post: 05-22-2009, 01:08 AM -
Color cell in JTable
By ippacciani in forum AWT / SwingReplies: 3Last Post: 03-25-2009, 11:53 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks