javax.swing.table.AbstractTableModel类的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(196)

本文整理了Java中javax.swing.table.AbstractTableModel类的一些代码示例,展示了AbstractTableModel类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractTableModel类的具体详情如下:
包路径:javax.swing.table.AbstractTableModel
类名称:AbstractTableModel

AbstractTableModel介绍

暂无

代码示例

代码示例来源:origin: RipMeApp/ripme

});
historyButtonRemove.addActionListener(event -> {
  int[] indices = historyTable.getSelectedRows();
  for (int i = indices.length - 1; i >= 0; i--) {
    int modelIndex = historyTable.convertRowIndexToModel(indices[i]);
    HISTORY.remove(modelIndex);
    historyTableModel.fireTableDataChanged();
  } catch (Exception e) { }
  saveHistory();
    checkChoise.add(yesButton);
    checkChoise.add(noButton);
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame("Are you sure?");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(checkChoise);
    frame.setSize(405, 70);
      HISTORY.clear();
      try {
        historyTableModel.fireTableDataChanged();
      } catch (Exception e) {
    HISTORY.clear();
    try {
      historyTableModel.fireTableDataChanged();
    } catch (Exception e) {

代码示例来源:origin: chewiebug/GCViewer

/**
 * @see javax.swing.table.AbstractTableModel#getColumnName(int)
 */
@Override
public String getColumnName(int column) {
  String name = null;
  if (column < columnNames.size() && (column >= 0)) {
    name = columnNames.get(column);
  }
  return (name == null) ? super.getColumnName(column) : name;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public synchronized void fastRefresh() {
 _filteredRecords.remove(0);
 fireTableRowsDeleted(0, 0);
}

代码示例来源:origin: camunda/camunda-bpm-platform

if (index < 1) {
  LOG.warn("In strange state");
  fireTableDataChanged();
} else {
  fireTableRowsInserted(0, index - 1);
fireTableDataChanged();

代码示例来源:origin: stackoverflow.com

private JFrame frame = new JFrame("JTable RowHeader");
private JScrollPane scrollPane;
private JTable table;
  table = new JTable(4, 4);
  for (int i = 0; i < table.getRowCount(); i++) {
    table.setValueAt(i, i, 0);
  sorter = new TableRowSorter<TableModel>(table.getModel());
      model.fireTableDataChanged();
      model.fireTableRowsUpdated(0, model.getRowCount() - 1);
  scrollPane = new JScrollPane(table);
  scrollPane.setRowHeaderView(headerTable);
  table.setPreferredScrollableViewportSize(table.getPreferredSize());
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.add(scrollPane);
  frame.add(new JButton(new AbstractAction("Toggle filter") {
  frame.pack();
  frame.setLocation(150, 150);
  frame.setVisible(true);

代码示例来源:origin: stackoverflow.com

JTable table = new JTable(model);
  JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new JScrollPane(table));
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
fireTableRowsInserted(rowCount, rowCount);

代码示例来源:origin: stackoverflow.com

Component comp = super.prepareRenderer(renderer, row, column);
    if (!isRowSelected(row)) {
      int modelRow = convertRowIndexToModel(row);
      boolean type = (Boolean) getModel().getValueAt(modelRow, 2);
tableScroll = new JScrollPane(dialogTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
tableScroll.setBorder(null);
tableModel.addTableModelListener(new TableModelListener() {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout(10, 10));
  this.fireTableStructureChanged();
  this.fireTableDataChanged();
  this.fireTableStructureChanged();
  this.fireTableDataChanged();
  aRow.remove(col);
  aRow.insertElementAt(newVal, col);
  fireTableCellUpdated(row, col);
  this.fireTableStructureChanged();

代码示例来源:origin: stackoverflow.com

dataList.clear();
  dataList.addAll(inAccs);
  this.fireTableDataChanged();
JFrame f = new JFrame("Test");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
AccountTableModel model = new AccountTableModel();
LinkedList<Account> list = new LinkedList<>();
list.add(new Account());
model.setNewAccounts(list);
f.add(new JScrollPane(new JTable(model)));
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame("TableDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    { "5", "3" } };
JTable table = new JTable();
MyModel model = new MyModel(Color.RED, table.getBackground());
model.setDataVector(data, columnNames);
table.setModel(model);
table.setColumnSelectionAllowed(true);
table.setDefaultRenderer(Object.class, new TestCellRenderer());
    .addListSelectionListener(listener);
JScrollPane scrollPane = new JScrollPane(table);
contentPanel.add(scrollPane);
frame.add(contentPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
  fireTableRowsUpdated(0, getRowCount());

代码示例来源:origin: stackoverflow.com

JTable table = new JTable(tableData);
 ra.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 ra.setSize(400, 300);
 ra.setVisible(true);
 setLayout(new BorderLayout());
 add(new JScrollPane(table), BorderLayout.CENTER);
 textField.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent event) {
 add(textField, BorderLayout.SOUTH);
 fireTableDataChanged();

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(new TestPane());
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
setLayout(new BorderLayout());
JTable table = new JTable(new MultiplicationTableMode());
add(new JScrollPane(table));
      columns.set(index, intValue * index);
    fireTableRowsUpdated(rowIndex, rowIndex);

代码示例来源:origin: stackoverflow.com

public void run()
  JFrame f = new JFrame();
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  JScrollPane scrollpane = new JScrollPane(table);
  p.add(scrollpane, BorderLayout.CENTER);
  table.setRowHeight(28);
  table.setBackground(Color.DARK_GRAY);
  table.setForeground(Color.WHITE);
      ((AbstractTableModel) table.getModel()).fireTableStructureChanged();
  enableButton.setAction(enableAction);
  p.add(enableButton, BorderLayout.NORTH);
  f.add(p);
  f.pack();
  f.setVisible(true);

代码示例来源:origin: stackoverflow.com

JFrame f = new JFrame("Test");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
class MyTableModel extends AbstractTableModel {
    fireTableRowsInserted(n - 1, n - 1);
  public Dimension getPreferredScrollableViewportSize() {
    return new Dimension(super.getPreferredSize().width,
      getRowHeight() * getRowCount());
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
f.add(new JScrollPane(table));
f.add(new JButton(new AbstractAction("Add Row") {
  @Override
  public void actionPerformed(ActionEvent e) {
    model.addRow();
    f.pack();
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);

代码示例来源:origin: stackoverflow.com

tm.addData(new Data("R1C1", "R1C2"));
JTable table = new JTable(tm);
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
JFrame frame = new JFrame();
frame.setLayout(new GridLayout());
frame.add(scrollPane);
frame.pack();
frame.setSize(400, 150);
frame.setVisible(true);
  fireTableRowsInserted(dataList.size()-1, dataList.size()-1);

代码示例来源:origin: stackoverflow.com

model.add(Double.valueOf(30.1));
model.add(Double.valueOf("-30.2"));
JTable table = new JTable(model);
table.setPreferredScrollableViewportSize(table.getPreferredSize());
JScrollPane scrollPane = new JScrollPane(table);
add(scrollPane);
  public void run() {
    ExampleRemoveAddRows frame = new ExampleRemoveAddRows();
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  if (col == 0) {
    data.set(row, (Double) aValue);
    fireTableRowsUpdated(row, row);

代码示例来源:origin: stackoverflow.com

@Override
 public void run() {
  window.setVisible(true);
 data.add(rowElement);
 fireTableRowsInserted(data.size() - 1, data.size() - 1);
JTable theTable = new JTable(theModel);
contentPane.add(theTable, BorderLayout.CENTER);
this.add(theTable);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.pack();

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

public void removeToken(MergerToken token) {
  selectableTokensList.remove(token);
  excludedTokens.remove(token);
  AbstractTableModel model = (AbstractTableModel) view.getTokens().getModel();
  model.fireTableDataChanged();
}

代码示例来源:origin: omegat-org/omegat

@Override
  public void actionPerformed(ActionEvent e) {
    RowMapping mapping = new RowMapping();
    if (dialog.tableRepositories.getRowCount() == 1) {
      mapping.repoUrl = (String) dialog.tableRepositories.getValueAt(0, 1);
    }
    listMapping.add(mapping);
    int row = listMapping.size() - 1;
    modelMapping.fireTableRowsInserted(row, row);
    dialog.tableMapping.setRowSelectionInterval(row, row);
  }
});

代码示例来源:origin: omegat-org/omegat

@Override
  public void actionPerformed(ActionEvent e) {
    int r = dialog.tableRepositories.getSelectedRow();
    if (r >= 0) {
      listRepo.remove(r);
      modelRepo.fireTableRowsDeleted(r, r);
    }
  }
});

代码示例来源:origin: openpreserve/jhove

private void deleteModule ()
{
  ListSelectionModel ls = _modTable.getSelectionModel ();
  int selRow = ls.getMinSelectionIndex();
  if (selRow < 0) {
    return;       // no selection
  }
  _modules.remove (selRow);
  _modTableModel.fireTableRowsDeleted (selRow, selRow);
}

相关文章