Use instances of table (JTable) and tree (JTree) components in Java Swing

1: Table (JTable):

1. Basic concepts:

Table (JTable) is a new component of swing, which is mainly used to display data in the form of table It provides a simple mechanism for displaying large pieces of data

2. Common construction methods:

*JTable (): create a JTable instance using the system default model* JTable (int NumRows, int numcolumns): create an empty table with rows and columns specified by defaulttablemodel* JTable (object [] [] rowdata, object [] [] columnnames): create a table that displays two-dimensional data.

You can directly use the table column name array and table data array to create a table

*JTable (tablemodel DM): create a JTable instance that specifies the data schema and the default field schema.

Data model class objects are usually used to save data, while table model is created through table column name array and table data array

3. Common methods:

4. Comprehensive cases:

Code 1:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>