Class TableEditorsDemo

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class TableEditorsDemo extends JPanel
TableEditorsDemo, This class demonstrates how to use the picker classes inside of the cells of a JTable. (Note: The table editor classes can also work with a "SwingX" JXTable.) // Here is a "quick reference" example, for using the DatePicker table editor. // Create a table. JTable table = new JTable(new DemoTableModel()); // Add the DateTableEditor as the default editor and renderer for the LocalDate data type. table.setDefaultEditor(LocalDate.class, new DateTableEditor()); table.setDefaultRenderer(LocalDate.class, new DateTableEditor()); // Explicitly set the default editor and renderer for column index 0. // It's best to explicitly set the editors and renderers for the table columns, rather than // letting the JTable class decide which columns should have which editors and renders. TableColumn column = table.getColumnModel().getColumn(0); column.setCellEditor(table.getDefaultEditor(LocalDate.class)); column.setCellRenderer(table.getDefaultRenderer(LocalDate.class)); // That's it. // The cells in column 0 will now use a date picker for editing and rendering values.
See Also:
  • Constructor Details

    • TableEditorsDemo

      public TableEditorsDemo()
      Constructor, Set up the table instance, and add the table editors to the table.
  • Method Details

    • createAndShowTableDemoFrame

      public static void createAndShowTableDemoFrame()
      createAndShowTableDemoFrame, This creates and displays a frame with the table demo.
    • main

      public static void main(String[] args)
      main, The table demo can be run independently from this main method, or the table demo can be run by pressing the matching button in the "FullDemo" program.