本文整理汇总了Java中javax.swing.event.TableModelEvent.DELETE属性的典型用法代码示例。如果您正苦于以下问题:Java TableModelEvent.DELETE属性的具体用法?Java TableModelEvent.DELETE怎么用?Java TableModelEvent.DELETE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.event.TableModelEvent
的用法示例。
在下文中一共展示了TableModelEvent.DELETE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tableChanged
public void tableChanged(TableModelEvent e) {
Object blank = "";
if(e.getType() == TableModelEvent.UPDATE) {
if(e.getColumn() == TableModelEvent.ALL_COLUMNS) {
;
}
else if(e.getFirstRow() == TableModelEvent.HEADER_ROW) {
;
}
else {
if(e.getFirstRow() == numRows-1) {
if(getValueAt(e.getFirstRow(), e.getColumn()).equals(blank) == false) {
addEmptyRow();
}
}
}
}
else if(e.getType() == TableModelEvent.DELETE) {
}
}
示例2: tableChanged
public void tableChanged(TableModelEvent e) {
// If a row changed and is a complete entry(both x and y values)
// plot the points on the display.
if(e.getType() == TableModelEvent.UPDATE) {
Object blank = "";
if(e.getFirstRow() != TableModelEvent.HEADER_ROW) {
if(tableModel.getValueAt(e.getFirstRow(), 0).equals(blank) == false &&
tableModel.getValueAt(e.getFirstRow(), 1).equals(blank) == false) {
updateAction.actionPerformed();
}
}
}
// If a row is removed, remove it from the display.
else if(e.getType() == TableModelEvent.DELETE) {
updateAction.actionPerformed();
}
}
示例3: 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();
}
示例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: 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);
}