本文整理匯總了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);
}
}
}
}
示例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();
}
示例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();
}
}
示例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;
}
示例5: tableChanged
public void tableChanged(TableModelEvent e) {
super.tableChanged(e);
if (e.getType() == TableModelEvent.INSERT) updateColumns(false);
}
示例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);
}