extends DefaultTableModel to create your own table model and build table from that : Table Model « Swing JFC « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Swing JFC » Table ModelScreenshots 
extends DefaultTableModel to create your own table model and build table from that
extends DefaultTableModel to create your own table model and build table from that
    
import java.awt.BorderLayout;
import java.util.Vector;

import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;

public class TableSample2 {
  public static void main(String args[]) {
    Object rows[][] { { "one""ichi - \u4E00""un" },
        "two""ni - \u4E8C""deux" },
        "three""san - \u4E09""trois" },
        "four""shi - \u56DB""quatre" },
        "five""go - \u4E94""cinq" },
        "six""roku - \u516D""treiza" },
        "seven""shichi - \u4E03""sept" },
        "eight""hachi - \u516B""huit" },
        "nine""kyu - \u4E5D""neuf" },
        "ten""ju - \u5341""dix" }
    };
    Object options[] "un""deux""trois""quatre""cinq""treiza",
        "sept""huit""neuf""dix" };
    JComboBox comboBox = new JComboBox(options);
    comboBox.setMaximumRowCount(4);
    TableCellEditor editor = new DefaultCellEditor(comboBox);

    Object headers[] "English""Japanese""French" };
    JFrame frame = new JFrame("JTable Anatomy");
    class CustomTableModel extends DefaultTableModel {
      public CustomTableModel(Object rowData[][], Object columnNames[]) {
        super(rowData, columnNames);
      }

      public Class getColumnClass(int col) {
        Vector v = (VectordataVector.elementAt(0);
        return v.elementAt(col).getClass();
      }

      public boolean isCellEditable(int row, int col) {
        return true;
      }
    }
    JTable table = new JTable(new DefaultTableModel(rows, headers));

    //    ColumnModelUtilities.removeHeaders(table.getColumnModel());
    table.getColumnModel().getColumn(2).setCellEditor(editor);

    JScrollPane scrollPane = new JScrollPane(table);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300150);
    frame.setVisible(true);
  }
}

           
         
    
    
    
  
Related examples in the same category
1. Append a row to a table through DefaultTableModel at specified row
2. Remove the first row from a table with DefaultTableModel
3. Remove the last row from a table with DefaultTableModel
4. Move the first row to the end of the table
5. Move the last row to the beginning of the table
6. Move the first two rows to the end of the table
7. Move the last two rows to the start of the table
8. Get all the table data from DefaultTableModel
9. Copy (clone) the data from the second row
10. Overwrite the date from the first row with DefaultTableModel
11. Copy data from a table to a list
12. Insert a new column to a table
13. JTable class using default table models and a convenienceJTable class using default table models and a convenience
14. Table with a custom TableModelTable with a custom TableModel
15. extends AbstractTableModel to create custom modelextends AbstractTableModel to create custom model
16. Table model is based on call backTable model is based on call back
17. Hard code data in array for TableModelHard code data in array for TableModel
18. A JTable class using default table models and a convenience constructorA JTable class using default table models and a convenience constructor
19. Custom model, POJO and JTableCustom model, POJO and JTable
20. Custom table model, File data based ModelCustom table model, File data based Model
21. Paging or pagable JTable(Table) Model for large data setPaging or pagable JTable(Table) Model for large data set
22. Paging JTable(Table) Model with an input field for dynamically altering the size of a page.Paging JTable(Table) Model with an input field for dynamically altering the size of a page.
23. File data Table: file name, size, type File data Table: file name, size, type
24. Stocks data Table: illustrate the TableModel Stocks data Table: illustrate the TableModel
25. Investment data Table Investment data Table
26. AbstractTableModel backed by HashtableAbstractTableModel backed by Hashtable
27. Fixed data vs dynamic data TableFixed data vs dynamic data Table
28. Use model to control the Editable ColumnsUse model to control the Editable Columns
29. Converts a visible column index to a column index in the model.
30. Converts a column index in the model to a visible column index
31. Returns the visible columns in the order that they appear in the model
32. Appending a Column to a JTable Component using DefaultTableModel
33. Add a column with values.
34. Disable autoCreateColumnsFromModel
35. Add a column without affecting existing columns
36. Remove the first visible column without removing the underlying data
37. Sharing a Table Model Between JTable Components
38. Creating simple JTable using AbstractTableModel
39. Map TableModel
40. TableSorter extends AbstractTableModel
41. TableSorter is a decorator for TableModels
42. Bean Property Table Model
43. A simple extension of JTable that supports the use of a SortableTableModel.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.