當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultTableModel.addTableModelListener方法代碼示例

本文整理匯總了Java中javax.swing.table.DefaultTableModel.addTableModelListener方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTableModel.addTableModelListener方法的具體用法?Java DefaultTableModel.addTableModelListener怎麽用?Java DefaultTableModel.addTableModelListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.table.DefaultTableModel的用法示例。


在下文中一共展示了DefaultTableModel.addTableModelListener方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deletecol

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
 * Delete a single column from the table model
 *
 * @param table target table
 * @param col target column
 * @deprecated
 */
static void deletecol(JTable table, int col) {
    DefaultTableModel tmodel = (DefaultTableModel) table.getModel();
    DefaultTableModel tmodel1 = new DefaultTableModel();
    TableModelListener[] listeners = tmodel.getTableModelListeners();

    Vector<?> v = tmodel.getDataVector();
    Vector<?> v1 = newvector(v, col);
    tmodel1.setDataVector(v1, getColumnIdentifiersremovecol(table, col));
    table.setModel(tmodel1);
    for (TableModelListener l : listeners) {
        tmodel1.addTableModelListener(l);
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:21,代碼來源:JtableUtils.java

示例2: addcol

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
 * Adding column is done by creating new model by modifying older one.<p>
 *
 * Insert new column if column is outside the <code>limit</code> Adds new
 * column if selected column inside the <code>limit</code>[email protected] _table
 * target table
 *
 * @param limit the range to avoid inserting
 */
static void addcol(JTable table, int limit) {
    try {
        int sc = table.getSelectedColumn();
        if (sc < limit - 1) {
            sc = table.getColumnCount() - 1;
        }

        DefaultTableModel tableM = (DefaultTableModel) table.getModel();
        DefaultTableModel tableM1 = new DefaultTableModel();
        TableModelListener[] listeners = tableM.getTableModelListeners();

        tableM1.setDataVector(newvectoraddcol(tableM.getDataVector(), sc), getColumnIdentifiersaddcol(sc + 1, table));
        table.setModel(tableM1);
        for (TableModelListener l : listeners) {
            tableM1.addTableModelListener(l);
        }

    } catch (Exception ex) {
        Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:32,代碼來源:JtableUtils.java

示例3: QueryBuilderGraphFrame

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
public QueryBuilderGraphFrame(
	QueryBuilder queryBuilder,
	QueryBuilderInputTable queryBuilderInputTable,
	JEditorPane sqlTextArea,
	DefaultTableModel resultTableModel)
    {
        super(new BorderLayout());
        
	Log.getLogger().entering("QueryBuilderGraphFrame", "constructor"); // NOI18N
        
        _queryBuilder = queryBuilder;
        _queryBuilderInputTable = queryBuilderInputTable;
        _inputTableModel = (DefaultTableModel) _queryBuilderInputTable.getModel();
        _sqlTextArea = sqlTextArea;
        _resultTableModel = resultTableModel;
        
        // Listen for events in the input table (column list)
        // Unfortunately, this gets triggered with every change to the model.
        // We need a way to make a group of changes to the input table, then invoke the
        // listener once at the end.
        _inputTableModel.addTableModelListener(this);
        
        // Get a list of tables in the DB
        
        JMenu menu, subMenu;
        JMenuItem menuItem;
        
        // Create three listeners
        _fsl = new FrameSelectionListener();
        // _fcl = new FrameComponentListener();
        _cl = new CompListener();
                
        // Create two popup menus
        _backgroundPopup = createBackgroundPopup();
        _tableTitlePopup = createTableTitlePopup();
        
        // Add listener to components that can bring up popup menus.
        // Create a listener that will bring up background menu
        // MouseListener backgroundPopupListener = new BackgroundPopupListener();
        
        // Add it as listener
//        _graph.addMouseListener(backgroundPopupListener);
//         _desktopPane.addMouseListener(backgroundPopupListener);
//         _desktopScrollPane.addMouseListener(backgroundPopupListener);
        
        // Create a new listener for noticing graph selection
//        _graph.addGraphSelectionListener(new GraphSelListener());
        
        // Add the JScrollPane to the QueryBuilderGraphFrame
//        this.add(_desktopScrollPane,BorderLayout.CENTER);
        
        // Make the GraphFrame visible
        setVisible(true);
        
//         _dropTarget = new DropTarget(_queryBuilder.getQueryBuilderPane()._qbSceneView,
// 				     DnDConstants.ACTION_COPY_OR_MOVE, this);
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:58,代碼來源:QueryBuilderGraphFrame.java

示例4: setUpMacrosTable

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
public void setUpMacrosTable() {
    final DefaultTableModel tableModel = new DefaultTableModel(new Object[]{"Macro", "For string", ""}, 0);
    macrosTable.setModel(tableModel);
    macrosTable.getColumnModel().getColumn(2).setResizable(false);
    macrosTable.getColumnModel().getColumn(2).setPreferredWidth(20);
    macrosTable.getColumnModel().getColumn(2).setMaxWidth(20);
    macrosTable.getColumnModel().getColumn(2).setMinWidth(20);
    for (int i = 0; i < grammar.macros.size(); i++) {
        tableModel.addRow(new Object[]{grammar.macros.get(i).getKey(), grammar.macros.get(i).getValue(), "-"});
    }
    tableModel.addRow(new Object[]{"", "", "+"});

    ButtonColumn b = new ButtonColumn(macrosTable, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JTable table = (JTable) e.getSource();
            int modelRow = Integer.valueOf(e.getActionCommand());
            if (modelRow < grammar.macros.size()) {
                grammar.removeMacro(modelRow);
                ((DefaultTableModel) table.getModel()).removeRow(modelRow);
                for (Graph graph : grammar.getGraphs().values())
                    for (GraphNode gn : graph.getGraphNodes().values())
                        graphEditor.renderingInfos.get(gn).formatDirty = true;
                graphEditor.updateUI();

            } else {
                table.getModel().setValueAt("-", modelRow, 2);
                grammar.macros.add(null);
                ((DefaultTableModel) table.getModel()).addRow(new Object[]{"", "", "+"});
            }
        }
    }, 2);

    tableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent tableModelEvent) {
            if (tableModelEvent.getColumn() == 2 || tableModelEvent.getColumn() == -1)
                return;
            int row = tableModelEvent.getLastRow();
            if (row == tableModel.getRowCount() - 1) {
                grammar.macros.add(null);
                tableModel.setValueAt("-", row, 2);
                ((DefaultTableModel) tableModel).addRow(new Object[]{"", "", "+"});
            }

            if (tableModel.getValueAt(row, 0).toString().trim().isEmpty() || tableModel.getValueAt(row, 1).toString().trim().isEmpty())
                grammar.macros.set(row, null);
            else
                grammar.macros.set(row, new Pair<String, String>(tableModel.getValueAt(row, 0).toString(), tableModel.getValueAt(row, 1).toString()));
        }
    });
}
 
開發者ID:radsimu,項目名稱:UaicNlpToolkit,代碼行數:53,代碼來源:GrammarEditor.java


注:本文中的javax.swing.table.DefaultTableModel.addTableModelListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。