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

📄 e906. creating a jtable component.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
The following creates a table that uses an efficient underlying storage implementation. Although cell values can be changed, rows and columns cannot be added or deleted. 
    // Create with initial data
    Object[][] cellData = {
        {"row1-col1", "row1-col2"},
        {"row2-col1", "row2-col2"}};
    String[] columnNames = {"col1", "col2"};
    
    JTable table = new JTable(cellData, columnNames);

The following creates tables that allow rows and columns to be added or deleted: 
    // Create a table with empty cells
    int rows = 10;
    int cols = 5;
    table = new JTable(rows, cols);
    
    // Create a table with initial data
    Vector rowData = new Vector();
    for (int i=0; i<cellData.length; i++) {
        Vector colData = new Vector(Arrays.asList(cellData[i]));
        rowData.add(colData);
    }
    Vector columnNamesV = new Vector(Arrays.asList(columnNames));
    
    table = new JTable(rowData, columnNamesV);

⌨️ 快捷键说明

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