コード例 #1
0
ファイル: BeanTableDataModel.java プロジェクト: KenC57/JMRI
  /**
   * Create a new table.
   *
   * @param sorter the sorter and model for the table
   * @return a new table
   * @deprecated since 4.5.4; use {@link #makeJTable(java.lang.String, javax.swing.table.TableModel,
   *     javax.swing.RowSorter)} instead.
   */
  @Deprecated
  public JTable makeJTable(TableSorter sorter) {
    JTable table = new JTable(sorter);
    table.getTableHeader().setReorderingAllowed(true);
    table.setColumnModel(new XTableColumnModel());
    table.createDefaultColumnsFromModel();

    addMouseListenerToHeader(table);
    return table;
  }
コード例 #2
0
ファイル: BeanTableDataModel.java プロジェクト: KenC57/JMRI
  /**
   * Create and configure a new table using the given model and row sorter.
   *
   * @param name the name of the table
   * @param model the data model for the table
   * @param sorter the row sorter for the table; if null, the table will not be sortable
   * @return the table
   * @throws NullPointerException if name or model are null
   */
  public JTable makeJTable(
      @Nonnull String name,
      @Nonnull TableModel model,
      @Nullable RowSorter<? extends TableModel> sorter) {
    Objects.requireNonNull(name, "the table name must be nonnull");
    Objects.requireNonNull(model, "the table model must be nonnull");
    JTable table = new JTable(model);
    table.setName(name);
    table.setRowSorter(sorter);
    table.getTableHeader().setReorderingAllowed(true);
    table.setColumnModel(new XTableColumnModel());
    table.createDefaultColumnsFromModel();

    addMouseListenerToHeader(table);
    return table;
  }