⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e908. appending a row to a jtable component.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
To add a row of data to a JTable component, you need to add it to its table model. A simple implementation of a table model that supports appending row data is DefaultTableModel. By default, a table uses a DefaultTableModel. 
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);
    
    // Create a couple of columns
    model.addColumn("Col1");
    model.addColumn("Col2");
    
    // Append a row
    model.addRow(new Object[]{"v1", "v2"});
    // there are now 2 rows with 2 columns
    
    // Append a row with fewer values than columns.
    // The left-most fields in the new row are populated
    // with the supplied values (left-to-right) and fields
    // without values are set to null.
    model.addRow(new Object[]{"v1"});
    // there are now 3 rows with 2 columns
    
    // Append a row with more values than columns.
    // The extra values are ignored.
    model.addRow(new Object[]{"v1", "v2", "v3"});
    // there are now 4 rows with 2 columns

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -