ADDING STRING ARRAY OBJECT
ELEMENTS IN JTABLE IN JAVA:-
String col[]
= {"FOOD ID","FOOD NAME","FOOD CATEGORY",
"COST"};
tableModel = new
DefaultTableModel(col, 0);
jTable1.setModel(tableModel);
try {
String
fid=”1”;
String fname=”Data 1”;
String fcateg=”data 2”;
String cost=”20”;
Object[]
objs1 = {fid, fname, fcateg, cost};
tableModel.addRow(objs1);
}
}
catch
(IOException | NumberFormatException ex)
{
Logger.getLogger(FoodHome.class.getName()).log(Level.SEVERE, null, ex);
}
No comments:
Post a Comment