A good table control JTABLE is provided in Java, which we can easily populate data and display it, the following is the specific implementation of Java code:
/ / Define a JTABLE class
JTable TBL_PARAMS = New JTABLE ();
// Define the row data information container of the table. Vector Srcdata = new vector ();
// Initialize the column header of the table and related data information containers string [] columnName = {"Parameter name", "parameter value"}
// Set the column header Vector CNAME = New Vector (2); cName.Add (ColumnName [0]); cName.Add (ColumnName [1]);
DefaultTableModel Model = New DefaultTableModel (SDATA, CNAME); TBL_PARAMS.SETMODEL (MODEL);
// Fill data demo
Vector rowdata = new vector (2);
RowData.Add ("parameter name one");
RowData.Add ("Parameter Value One");
// Add the data to the container, which is added to JTABLE
Srcdata.add (rowdata);
......
// Finally refresh the JTABLE control
THIS.TBL_PARAMS.REPAINT (); this.tbl_params.Updateui ();