来自Servlet页面的输出值正确,但这些值不会更新到Java JTable的行中。 行计数在JTable中递增但在Java GUI中没有刷新(显示)。
将数据添加到表格的行 - >
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
try{
//*****************slno***************************/
String slno = request.getParameter("slno");
a = slno;
System.out.println("Source id--->: "+demo123.a);
out.println("<p>slno: " + slno + "</p>");
//*****************lattitude***************************/
String lattitude = request.getParameter("lattitude");
b = lattitude;
System.out.println("lattitude--->: "+demo123.b);
out.println("<p>lattitude: " + lattitude + "</p>");
//*****************longitude***************************/
String longitude = request.getParameter("longitude");
c = longitude;
System.out.println("longitude--->: "+ demo123.c);
out.println("<p>longitude: " + longitude + "</p>");
ServerGUI.rows=ServerGUI.table.getRowCount();
System.out.println("row count"+ServerGUI.table.getRowCount());
ServerGUI.Tmodel.addRow(new Object[]{a,b,c});
System.out.println( "Row count :" + ((DefaultTableModel)ServerGUI.table.getModel()).getRowCount());
ServerGUI.table.repaint();
} catch (Exception e) {}
}
Java GUI程序中的GUI JTable方法 - &gt;
table = new JTable();
Tmodel = new DefaultTableModel(0,0);
String header[] = new String[]{"SOURCE ID", "LATTITUDE", "LONGITUDE"};
Tmodel.setColumnIdentifiers(header);
table.setModel(Tmodel);