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


Java TableModelEvent.getType方法代碼示例

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


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

示例1: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
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) {
            }
    	}
 
開發者ID:etomica,項目名稱:etomica,代碼行數:23,代碼來源:DeviceTableModelGeneric.java

示例2: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
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();
   	}
}
 
開發者ID:etomica,項目名稱:etomica,代碼行數:18,代碼來源:DevicePlotPoints.java

示例3: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
/**
     * 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,代碼行數:23,代碼來源:GravLangFileEditor.java

示例4: tableModelEventToString

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
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,代碼行數:31,代碼來源:EventBroadcaster.java

示例5: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
/**
 * Overridden for efficiency reasons (provides a better calculation of the 
 * dirty region). See 
 * <a href="http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/">this page</a>
 * for a more complete discussion. 
 */
@Override
public void tableChanged(TableModelEvent e) {
  //if just an update, and not a data or structure changed event or an insert or delete, use the fixed row update handling
  //otherwise call super.tableChanged to let the standard JTable update handling manage it
  if ( e != null &&
      e.getType() == TableModelEvent.UPDATE &&
      e.getFirstRow() != TableModelEvent.HEADER_ROW &&
      e.getLastRow() != Integer.MAX_VALUE) {
      handleRowUpdate(e);
  } else {
      super.tableChanged(e);
  }
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:20,代碼來源:XJTable.java

示例6: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent e) {
    if (e.getType() == TableModelEvent.UPDATE && e.getColumn() == 0) {
        int mci = 0;
        int vci = table.convertColumnIndexToView(mci);
        TableColumn column = table.getColumnModel().getColumn(vci);
        Object title = column.getHeaderValue();
        if (!Status.INDETERMINATE.equals(title)) {
            column.setHeaderValue(Status.INDETERMINATE);
        } else {
            int selected = 0, deselected = 0;
            TableModel m = table.getModel();
            for (int i = 0; i < m.getRowCount(); i++) {
                if (Boolean.TRUE.equals(m.getValueAt(i, mci))) {
                    selected++;
                } else {
                    deselected++;
                }
            }
            if (selected == 0) {
                column.setHeaderValue(Status.DESELECTED);
            } else if (deselected == 0) {
                column.setHeaderValue(Status.SELECTED);
            } else {
                return;
            }
        }
        table.getTableHeader().repaint();
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:31,代碼來源:TableCheckBoxColumn.java

示例7: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@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,代碼行數:16,代碼來源:Timer.java

示例8: translateEvent

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
/** Creates a TableModelEvent identical to the original except that the
 * column index has been shifted by +1.  This is used to refire events
 * from the ProxyTableModel (generated by RowModel.setValueFor()) as 
 * change events on the OutlineModel. */
private TableModelEvent translateEvent (TableModelEvent e) {
    TableModelEvent nue = new TableModelEvent (getModel(),
        e.getFirstRow(), e.getLastRow(), e.getColumn()+1, e.getType());
    return nue;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:EventBroadcaster.java

示例9: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
public void tableChanged(TableModelEvent evt) {
    if (evt.getType() == TableModelEvent.UPDATE) {
        validateTable(evt.getFirstRow(), evt.getColumn());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:AnnotationSettings.java

示例10: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
public void tableChanged(TableModelEvent e) {
    super.tableChanged(e);
    if (e.getType() == TableModelEvent.INSERT) updateColumns(false);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:5,代碼來源:DetailsTable.java

示例11: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent tme) {
	
	if(tme.getSource()==this && tme.getFirstRow()>=0){
		
		if(tme.getType()==TableModelEvent.UPDATE){
			// --- Update Events in the table ---------
			if(tme.getColumn() > 0){
				// --- A single value was edited ------------------------------------
				int seriesIndex = tme.getColumn()-1; // First column contains the time stamps.
				int rowIndex = tme.getFirstRow();
				
				Number key = (Number) this.getValueAt(rowIndex, 0);
				Number value = (Number) this.getValueAt(rowIndex, tme.getColumn());
				Vector<Number> rowVector = this.getRow(rowIndex);
				
				try {
					if(value!=null){
						// --- Update new entry in chart and ontology model ---------
						this.getChartModel().addOrUpdateValuePair(seriesIndex, key, value);
						this.getOntologyModel().addOrUpdateValuePair(seriesIndex, key, value);
					
					} else {
						if (this.isEmptyTableModelRow(rowVector)==false) {
							// --- Rewrite the data row -----------------------------
							for (int i=1; i < rowVector.size(); i++) {
								Number seriesValue = (Number) rowVector.get(i);
								int series = i-1;
								if (seriesValue!=null) {
									this.getChartModel().addOrUpdateValuePair(series, key, seriesValue);
									this.getOntologyModel().addOrUpdateValuePair(series, key, seriesValue);
								} else {
									this.getChartModel().removeValuePair(series, key);
									this.getOntologyModel().removeValuePair(series, key);
								}
							} // end for
							
						} else {
							// --- Empty row, delete ValuePair ----------------------
							this.getChartModel().removeValuePair(seriesIndex, key);
							this.getOntologyModel().removeValuePair(seriesIndex, key);
						}
					}
					
				} catch (NoSuchSeriesException e) {
					System.err.println("Error updating data model: Series "+seriesIndex+" does mot exist!");
					e.printStackTrace();
				}
			
			} else if(tme.getColumn() == 0) {
				// --- The key value (e.g. the time stamp) was edited ---------------
				Number oldKey = (Number) this.getLatestChangedValue();
				Number newKey = (Number) this.getValueAt(tme.getFirstRow(), 0);
				
				this.getChartModel().updateKey(oldKey, newKey);
				this.getOntologyModel().updateKey(oldKey, newKey);
			}
			
		} 
		
	}

}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:64,代碼來源:TimeSeriesTableModel.java

示例12: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent tme) {
	
	if(tme.getSource()==this && tme.getFirstRow()>=0){
		
		if(tme.getType()==TableModelEvent.UPDATE){
			// --- Update Events in the table ---------------------------------------
			try {
				int rowIndex = tme.getFirstRow();
				int colIndex = tme.getColumn();
				Vector<Number> rowVector = this.getRow(rowIndex);
				Float xValue = (Float) rowVector.get(1);
				Float yValue = (Float) rowVector.get(2);
				
				// --- Do we have changes? ------------------------------------------
				if (colIndex==1) {
					if (((Float)this.latestChangedValue).equals(xValue)) return;
					if (this.getOntologyModel().getSeries(this.getFocusedSeriesIndex()).getAvoidDuplicateXValues()==true) {
						// --- Risk of duplicate x values ? -------------------------
						if (this.tableModelDataVector.getRowByValue(colIndex, xValue, rowIndex)!=null) {
							// --- Another row contains this value, undo ------------
							String title = "Doppelte X-Werte nicht zulässig!";
							String msg = "Doppelte X-Werte sind derzeit nicht zulässig!\n";
							msg += "Die Aktion wird rückgängig gemacht.";
							
							JOptionPane.showMessageDialog(this.myJTable, Language.translate(msg), Language.translate(title), JOptionPane.WARNING_MESSAGE, null);
							xValue = (Float) this.latestChangedValue;
							this.tableModelDataVector.get(rowIndex).set(colIndex, xValue);
							return;
						}
					}
				} else if (colIndex==2) {
					if (((Float)this.latestChangedValue).equals(yValue)) return;
				}
				
				// --- A value of a series was edited -------------------------------
				if(xValue!=null && yValue!=null){
					// --- Update new entry in chart and ontology model --------
					this.getOntologyModel().updateXyValuePair(this.getFocusedSeriesIndex(), rowIndex, xValue, yValue);
					if (this.getOntologyModel().getSeries(this.getFocusedSeriesIndex()).getAutoSort()==true) {
						this.tableModelDataVector.sort();
						this.getOntologyModel().getSeries(this.getFocusedSeriesIndex()).sort();
						// --- Find new position of the row vector -------------  
						rowIndex = this.tableModelDataVector.indexOf(rowVector);
					}
					this.getChartModel().setXYSeriesAccordingToOntologyModel(this.getFocusedSeriesIndex());
					if (rowIndex!=-1) {
						int rowIndexTable = this.myJTable.convertRowIndexToView(rowIndex);
						this.myJTable.setRowSelectionInterval(rowIndexTable, rowIndexTable);
						this.myJTable.changeSelection(rowIndexTable, 0, false, false);
					}
					
				} else {
					// --- We have an empty yValue, delete ValuePair ------------
					this.tableModelDataVector.remove(rowIndex);
					if (this.getRowCount()==0) {
						this.parentDataModel.removeSeries(this.getFocusedSeriesIndex());
					} else {
						this.getOntologyModel().removeXyValuePair(this.getFocusedSeriesIndex(), rowIndex);
						this.getChartModel().setXYSeriesAccordingToOntologyModel(this.getFocusedSeriesIndex());
					}
				}
				
			} catch (NoSuchSeriesException e) {
				System.err.println("Error updating data model: Series "+this.getFocusedSeriesIndex()+" does mot exist!");
				e.printStackTrace();
			}
			
		} else {
			// --- Insert or Delete events in the table ---------
		}
	}

}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:75,代碼來源:XyTableModel.java

示例13: initToolBar

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
/**
 * 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,代碼行數:52,代碼來源:PageTableModel.java

示例14: tableChanged

import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent e) {
    if (TableModelEvent.UPDATE == e.getType()) {
        this.onTableChage(e);
    }
}
 
開發者ID:vulnersCom,項目名稱:burp-vulners-scanner,代碼行數:7,代碼來源:RulesTableListener.java


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