Change Column Type of jtable when table populate from resultset

前端 未结 2 1940

I have worker for fill the jtable from resultset like below;

public class WorkerFillTable extends SwingWorker {
          


        
2条回答
  •  無奈伤痛
    2020-12-04 03:56

    JDBCAdapter, which extends AbstractTableModel, illustrates a typical mapping between relational database and Java data types. It may be seen here, and a complete example may be found in samples/demo/jfc/TableExample, found among the Java SE Development Kit 8u25 Demos and Samples Downloads. In outline,

    • Override getColumnClass().

    • Get the column's data type from ResultSetMetaData.

    • Use switch(type) to return the correct type-token.

    Also consider a SwingWorker for finer granularity in publish()/process().

提交回复
热议问题