当前位置: 首页>>代码示例>>Java>>正文


Java TableModelEvent.INSERT属性代码示例

本文整理汇总了Java中javax.swing.event.TableModelEvent.INSERT属性的典型用法代码示例。如果您正苦于以下问题:Java TableModelEvent.INSERT属性的具体用法?Java TableModelEvent.INSERT怎么用?Java TableModelEvent.INSERT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.swing.event.TableModelEvent的用法示例。


在下文中一共展示了TableModelEvent.INSERT属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tableChanged

/**
     * TableModel listener
     *
     * @param e
     */
    @Override
    public void tableChanged(TableModelEvent e) {
//        TODO Do something with the data...
        System.out.println(e.getType());
        if (e.getType() == TableModelEvent.INSERT) {
            //TODO update all files
//            TranslationTableModel model = (TranslationTableModel) editor.getTable1().getModel();
            String lang = editor.getCurrentLang();
            VirtualFile file = getFileMap().get(lang);
            if (file.exists()) {
                YAMLFileImpl yamlFile = (YAMLFileImpl) PsiManager.getInstance(project).findFile(file);
                if (yamlFile != null) {
                    System.out.println(yamlFile);
                }
            }
        }
    }
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:22,代码来源:GravLangFileEditor.java

示例2: tableModelEventToString

private static String tableModelEventToString (TableModelEvent e) {
    StringBuilder sb = new StringBuilder();
    sb.append ("TableModelEvent ");
    switch (e.getType()) {
        case TableModelEvent.INSERT : sb.append ("insert ");
             break;
        case TableModelEvent.DELETE : sb.append ("delete ");
             break;
        case TableModelEvent.UPDATE : sb.append ("update ");
             break;
        default : sb.append("Unknown type ").append(e.getType());
    }
    sb.append ("from ");
    switch (e.getFirstRow()) {
        case TableModelEvent.HEADER_ROW : sb.append ("header row ");
            break;
        default : sb.append (e.getFirstRow());
                  sb.append (' ');
    }
    sb.append ("to ");
    sb.append (e.getLastRow());
    sb.append (" column ");
    switch (e.getColumn()) {
        case TableModelEvent.ALL_COLUMNS :
            sb.append ("ALL_COLUMNS");
            break;
        default : sb.append (e.getColumn());
    }
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:EventBroadcaster.java

示例3: tableChanged

@Override
public void tableChanged(TableModelEvent e)
{
	super.tableChanged(e);
	if (e.getType() == TableModelEvent.INSERT)
		scrollToBottom();
	else if (e.getType() == 42)
	{
		finishcolor = (finishcolor+1)%2;
		totalRenderer.setHighlight(finishcolor);
		seqRenderer.setHighlight(finishcolor);
		getSelectionModel().setSelectionInterval(e.getFirstRow(), e.getLastRow());
		Toolkit.getDefaultToolkit().beep();
	}
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:15,代码来源:Timer.java

示例4: translateEvent

/** Translates tree expansion event into an appropriate TableModelEvent
 * indicating the number of rows added/removed at the appropriate index */
private TableModelEvent translateEvent (TreeExpansionEvent e, boolean expand) {
    //PENDING:  This code should be profiled - the descendent paths search
    //is not cheap, and it might be less expensive (at least if the table
    //does not have expensive painting logic) to simply fire a generic
    //"something changed" table model event and be done with it.
    
    TreePath path = e.getPath();
    
    //Add one because it is a child of the row.
    int firstRow = getLayout().getRowForPath(path) + 1;
    if (firstRow == -1) {
        //This does not mean nothing happened, it may just be that we are
        //a large model tree, and the FixedHeightLayoutCache says the
        //change happened in a row that is not showing.
        
        //TODO:  Just to make the table scrollbar adjust itself appropriately,
        //we may want to look up the number of children in the model and
        //fire an event that says that that many rows were added.  Waiting
        //to see if anybody actually will use this (i.e. fires changes in
        //offscreen nodes as a normal part of usage
        return null;
    }
    
    //Get all the expanded descendants of the path that was expanded/collapsed
    TreePath[] paths = getTreePathSupport().getExpandedDescendants(path);
    
    //Start with the number of children of whatever was expanded/collapsed
    int count = getTreeModel().getChildCount(path.getLastPathComponent());
    
    if (count == 0) {
        return null;
    }
    
    //Iterate any of the expanded children, adding in their child counts
    for (int i=0; i < paths.length; i++) {
        count += getTreeModel().getChildCount(paths[i].getLastPathComponent());
    }
    
    //Now we can calculate the last row affected for real
    int lastRow = firstRow + count -1;
    
    //Construct a table model event reflecting this data
    TableModelEvent result = new TableModelEvent (getModel(), firstRow, lastRow, 
        TableModelEvent.ALL_COLUMNS, expand ? TableModelEvent.INSERT : 
        TableModelEvent.DELETE);
        
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:EventBroadcaster.java

示例5: tableChanged

public void tableChanged(TableModelEvent e) {
    super.tableChanged(e);
    if (e.getType() == TableModelEvent.INSERT) updateColumns(false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:DetailsTable.java

示例6: initToolBar

/**
 * Initialize context menu and toolbar.
 */
private void initToolBar() {
    toolbar = new JToolBar();
    
    toolbar.add(new Button(firstPageAction));
    toolbar.add(new Button(pageUpAction));
    toolbar.add(new Button(pageDownAction));
    toolbar.add(new Button(lastPageAction));
    
    toolbar.addSeparator();
    toolbar.add(pageSizeLabel);
    toolbar.add(pageSizeField);
    pageSizeField.setText(Integer.toString(getPageSize()));
    pageSizeField.setHorizontalAlignment(JTextField.RIGHT);
    pageSizeField.setAction(pageSizeAction);
    pageSizeField.setMaximumSize(pageSizeField.getPreferredSize());
    
    toolbar.addSeparator();
    totalRowCountLabel.setText(String.format(totalRowCountLabelFormat, getRealRowCount()));
    toolbar.add(totalRowCountLabel);
    
    toolbar.add(pageField);
    pageField.setText(Integer.toString(getPage() + 1));
    pageField.setHorizontalAlignment(JTextField.RIGHT);
    pageField.setAction(gotoPageAction);
    pageField.setMaximumSize(pageField.getPreferredSize());
    
    pageCountLabel.setText(String.format(pageCountLabelFormat, getPageCount()));
    toolbar.add(pageCountLabel);
    
    setActionEnabled();
    
    TableModelListener listener = new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent tme) {
            if (tme.getType() == TableModelEvent.INSERT || tme.getType() == TableModelEvent.DELETE) {
                if (getPage() >= getPageCount()) {
                    setPage(getPageCount() - 1);
                }

                totalRowCountLabel.setText(String.format(totalRowCountLabelFormat, getRealRowCount()));
                pageField.setText(Integer.toString(getPage() + 1));
                pageCountLabel.setText(String.format(pageCountLabelFormat, getPageCount()));
            }
        }
    };
    
    addTableModelListener(listener);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:51,代码来源:PageTableModel.java


注:本文中的javax.swing.event.TableModelEvent.INSERT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。