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


Java DefaultTableModel.getValueAt方法代碼示例

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


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

示例1: fireChanged

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void fireChanged() {
    DefaultTableModel model = (DefaultTableModel) table.getModel();
    ArrayList<String> patterns = new ArrayList<String>(model.getRowCount());
    for (int i = 0; i < model.getRowCount(); i++) {
        Object value = model.getValueAt(i, 0);
        if (value == null) {
            continue;
        }
        String pattern = value.toString();
        //remove empty patterns
        if (!pattern.trim().isEmpty() && !pattern.trim().equals(getDummyPattern())) {
            patterns.add(pattern);
        }
    }
    changed = !id2comments.isEmpty()
            || Settings.getDefault().isScanCommentsOnly() != checkScanCommentsOnly.isSelected()
            || Settings.getDefault().getPatterns().size() != patterns.size()
            || !Settings.getDefault().getPatterns().containsAll(patterns)
            || Settings.getDefault().getExtensionIdentifiers().size() != extensionIdentifiers.size()
            || !Settings.getDefault().getExtensionIdentifiers().containsAll(extensionIdentifiers)
            || Settings.getDefault().getMimeIdentifiers().size() != mimeIdentifiers.size()
            || !Settings.getDefault().getMimeIdentifiers().containsAll(mimeIdentifiers);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ToDoCustomizer.java

示例2: renameDomainInComponents

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
 * Rename domain in components.
 *
 * @param oldDomainName the old domain name
 * @param newDomainName the new domain name
 */
public void renameDomainInComponents(String oldDomainName, String newDomainName) {
	
	DefaultTableModel dtmComponents = this.getTableModel4ComponentTypes();
	int column = getColumnHeaderIndexComponents(COL_Domain);
	
	// --- Get the component type definitions from table ----
	JTable jtComponents = this.getJTable4ComponentTypes();
	// --- Confirm, apply changes in table ------------------						
	TableCellEditor tceComponents = jtComponents.getCellEditor();
	if (tceComponents!=null) {
		tceComponents.stopCellEditing();
	}
	for(int row=0; row<dtmComponents.getRowCount(); row++){
		String currValue = (String) dtmComponents.getValueAt(row, column);
		if (currValue.equals(oldDomainName)) {
			dtmComponents.setValueAt(newDomainName, row, column);	
		}
	}
	this.setTableCellEditor4DomainsInComponents(null);
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:27,代碼來源:ComponentTypeDialog.java

示例3: convertTableModelToStringValue

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private String convertTableModelToStringValue(DefaultTableModel tableModel) {
    StringBuilder stringBuilder = new StringBuilder();
    int rowCount = tableModel.getRowCount();
    for (int i = 0; i < rowCount; i++) {
        String option = (String) tableModel.getValueAt(i, 0);
        try {
            Double min = Double.parseDouble((String) tableModel.getValueAt(i, 1));
            Double max = Double.parseDouble((String) tableModel.getValueAt(i, 2));
            String colorValue = (String) tableModel.getValueAt(i, 3);
            stringBuilder.append(option + "=" + min + ".." + max + "->" + colorValue + ",");
        } catch (Throwable skip) {
            stringBuilder.append(option + "=" + 0 + ".." + 0 + "->" + "#FFFFFFFF" + ",");
        }
    }
    return stringBuilder.toString();
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:17,代碼來源:EditIntervalsColorScript.java

示例4: makeTemplateMessage

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
 * 組織模板消息
 *
 * @return
 */
synchronized public static WxMpTemplateMessage makeTemplateMessage() {
    // 拚模板
    WxMpTemplateMessage wxMessageTemplate = new WxMpTemplateMessage();
    wxMessageTemplate.setTemplateId(MainWindow.mainWindow.getMsgTemplateIdTextField().getText());
    wxMessageTemplate.setUrl(MainWindow.mainWindow.getMsgTemplateUrlTextField().getText());
    if (MainWindow.mainWindow.getTemplateMsgDataTable().getModel().getRowCount() == 0) {
        Init.initTemplateDataTable();
    }

    DefaultTableModel tableModel = (DefaultTableModel) MainWindow.mainWindow.getTemplateMsgDataTable().getModel();
    int rowCount = tableModel.getRowCount();
    for (int i = 0; i < rowCount; i++) {
        WxMpTemplateData templateData = new WxMpTemplateData((String) tableModel.getValueAt(i, 0), ((String) tableModel.getValueAt(i, 1)).replaceAll("#ENTER#", "\n"), ((String) tableModel.getValueAt(i, 2)).trim());
        wxMessageTemplate.addWxMpTemplateData(templateData);
    }

    return wxMessageTemplate;
}
 
開發者ID:rememberber,項目名稱:WePush,代碼行數:24,代碼來源:PushManage.java

示例5: checkDataValid

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
public boolean checkDataValid() {
    DefaultTableModel dtm = (DefaultTableModel) this.getModel();
    int rows = dtm.getRowCount();
    for (int i = 0 ; i < rows ; i++) {
    	String block = (String)dtm.getValueAt(i,0);
    	String timeToDwell = (String)dtm.getValueAt(i,1);
    	String timeToDest = (String)dtm.getValueAt(i,2);
    	
    	//Ignore if the last blank row, it is purposefully null
    	if(block == null && timeToDwell == null && timeToDest == null) {
    		continue;
    	}
    	
    	//Make sure row has a block and a time to dwell
    	if(block.equals("") || block==null || 
    			timeToDwell==null || !SimTime.isValid(timeToDwell)) {
    		return false;
    	}
    }
	return true;
}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:22,代碼來源:ScheduleJTable.java

示例6: moveUpVarButtonActionPerformed

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void moveUpVarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveUpVarButtonActionPerformed
    int index = childrenVariablesTable.getSelectedRow();
    if (index <= 0) return ;
    DefaultTableModel model = (DefaultTableModel) childrenVariablesTable.getModel();
    Object[] row = new Object[] { model.getValueAt(index, 0), model.getValueAt(index, 1) };
    model.removeRow(index);
    model.insertRow(index - 1, row);
    childrenVariablesTable.getSelectionModel().setSelectionInterval(index - 1, index - 1);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:VariableFormatterEditPanel.java

示例7: moveDownVarButtonActionPerformed

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void moveDownVarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveDownVarButtonActionPerformed
    int index = childrenVariablesTable.getSelectedRow();
    if (index < 0) return ;
    DefaultTableModel model = (DefaultTableModel) childrenVariablesTable.getModel();
    if (index >= (model.getRowCount() - 1)) return ;
    Object[] row = new Object[] { model.getValueAt(index, 0), model.getValueAt(index, 1) };
    model.removeRow(index);
    model.insertRow(index + 1, row);
    childrenVariablesTable.getSelectionModel().setSelectionInterval(index + 1, index + 1);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:VariableFormatterEditPanel.java

示例8: jTable1MouseClicked

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
    DefaultTableModel model = (DefaultTableModel)jTable1.getModel(); int row = jTable1.getSelectedRow();
    String base = (String) model.getValueAt(row, 1);
    if (base.equals("Base Editor")) {jButton3.setEnabled(false); jButton4.setEnabled(false); jButton5.setEnabled(false);}
    else {jButton3.setEnabled(true); jButton4.setEnabled(true); jButton5.setEnabled(true);}
    if (((String) model.getValueAt(row, 2)).equals("YES")) {jButton3.setEnabled(false);}
    else {jButton3.setEnabled(true);}
    String version = Plugins.get(jTable1.getSelectedRow()).version();
    String name = Plugins.get(jTable1.getSelectedRow()).getName();
    String description = Plugins.get(jTable1.getSelectedRow()).description();
    String author = Plugins.get(jTable1.getSelectedRow()).author();
    String source = Plugins.get(jTable1.getSelectedRow()).source();
    jLabel16.setText(name); jTextArea3.setText("Version : "+version+"\nAuthor : "+author+
    "\nSource : "+source+"\n\n\nPlugin Description : \n\n"+description);
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:16,代碼來源:PluginManager.java

示例9: getFields

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
public List<Field> getFields() {
    List<Field> fields = new ArrayList<>();
    List<String> ignoreList = new ArrayList<>();
    if (StringUtils.isNotBlank(settingManager.getVariables().getIgnoreFields())) {
        ignoreList = StringUtils.splitToList(settingManager.getVariables().getIgnoreFields(), ",", true);
    }

    DefaultTableModel tableModel = (DefaultTableModel) fieldTable.getModel();
    for (int i = 0; i < tableModel.getRowCount(); i++) {
        Field field = new Field();
        // field
        field.setField(tableModel.getValueAt(i, 0).toString());
        // field.setFieldType(tableModel.getValueAt(i, 1).toString()); // setColumnType設置
        // column and type
        field.setColumn(tableModel.getValueAt(i, 2).toString());
        Object sqlType = tableModel.getValueAt(i, 4);
        if (Objects.nonNull(sqlType)) {
            field.setSqlType(sqlType.toString());
        }
        field.setColumnType(tableModel.getValueAt(i, 3).toString());
        if (Objects.nonNull(tableModel.getValueAt(i, 5))) {
            field.setColumnSize(tableModel.getValueAt(i, 5).toString());
        }
        if (Objects.nonNull(tableModel.getValueAt(i, 6))) {
            field.setComment(tableModel.getValueAt(i, 6).toString());
        }
        // 過濾
        if (!ignoreList.contains(field.getColumn().toUpperCase().trim())) {
            fields.add(field);
        }
    }
    return fields;
}
 
開發者ID:hykes,項目名稱:CodeGen,代碼行數:34,代碼來源:TablePanel.java

示例10: editAction

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void editAction() {
    int selectedRow = varTable.getSelectedRow();
    if (selectedRow != -1) {
        DefaultTableModel tableModel = (DefaultTableModel) varTable.getModel();
        String oldKey = (String) tableModel.getValueAt(selectedRow, 0);
        String oldValue = (String) tableModel.getValueAt(selectedRow, 1);

        VariableEditDialog dialog = new VariableEditDialog();
        dialog.setTitle("Edit Variable");
        dialog.getKeyTextField().setText(oldKey);
        dialog.getValueTextField().setText(oldValue);

        dialog.getButtonOK().addActionListener(it -> {
            String key = dialog.getKeyTextField().getText().trim();
            String value = dialog.getValueTextField().getText().trim();

            tableModel.setValueAt(key, selectedRow, 0);
            tableModel.setValueAt(value, selectedRow, 1);
            dialog.setVisible(false);
        });

        dialog.setSize(300, 150);
        dialog.setAlwaysOnTop(true);
        dialog.setLocationRelativeTo(rootPanel);
        dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
        dialog.setResizable(false);
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        dialog.setVisible(true);
    }
}
 
開發者ID:hykes,項目名稱:CodeGen,代碼行數:31,代碼來源:VariableUI.java

示例11: writeTemplateData

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
 * 保持模板數據
 *
 * @param msgName 消息名稱
 * @throws IOException
 */
public void writeTemplateData(String msgName) throws IOException {
    File dir = new File("data/template_data/");
    File file = new File("data/template_data/" + msgName + ".csv");
    if (!file.exists()) {
        dir.mkdirs();
        file.createNewFile();
    }

    CSVWriter writer = new CSVWriter(new FileWriter(file));

    List<String[]> records = new ArrayList<String[]>();

    // 如果table為空,則初始化
    if (MainWindow.mainWindow.getTemplateMsgDataTable().getModel().getRowCount() == 0) {
        Init.initTemplateDataTable();
    }

    // 逐行讀取
    DefaultTableModel tableModel = (DefaultTableModel) MainWindow.mainWindow.getTemplateMsgDataTable()
            .getModel();
    int rowCount = tableModel.getRowCount();
    String[] arryData;
    for (int i = 0; i < rowCount; i++) {
        arryData = new String[3];
        arryData[0] = (String) tableModel.getValueAt(i, 0);
        arryData[1] = (String) tableModel.getValueAt(i, 1);
        arryData[2] = ((String) tableModel.getValueAt(i, 2)).trim();
        records.add(arryData);
    }

    // 寫入文件
    writer.writeAll(records);
    writer.close();
}
 
開發者ID:rememberber,項目名稱:WePush,代碼行數:41,代碼來源:MsgHisManage.java

示例12: tableChanged

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
@Override
  public void tableChanged(TableModelEvent tme) {

  	if (this.quiteTabelModelListener==true) return;
  	
int row = tme.getFirstRow();
int column = tme.getColumn();
	
DefaultTableModel model = (DefaultTableModel) tme.getSource();
if (column == 0 && row >= 0 && row < model.getRowCount()) {
	
    String oldCompID = this.currNetworkComponent.getId();
	String newCompID = (String) model.getValueAt(row, column);
    if (!oldCompID.equals(newCompID)) {
	
    	String message = null;
    	String title = "Warning";
    	
		if (newCompID == null || newCompID.length() == 0) {
		    // --- Check if the component id is empty
			message = "Enter a valid name";
		    JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
		    getJTableComponents().getModel().setValueAt(oldCompID, row, column);

		} else if (newCompID.contains(" ")) {
		    // --- Check for spaces
			message = "Enter the name without spaces";
		    JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
		    getJTableComponents().getModel().setValueAt(oldCompID, row, column);

		} else if (getGraphController().getNetworkModelAdapter().getNetworkComponent(newCompID) != null) {
		    // --- Check if a network component name already exists
			message = "The component name already exists!" + newLine + "Choose a different one.";
		    JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
		    getJTableComponents().getModel().setValueAt(oldCompID, row, column);

		} else if (this.getGraphController().getProject().getSimulationSetups().getCurrSimSetup().isAgentNameExists(newCompID)) {
		    // --- Check if the agent name already exists in the simulation setup
			message = "An agent with the name already exists in the simulation setup!" + newLine + " Choose a different one.";
			JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
		    getJTableComponents().getModel().setValueAt(oldCompID, row, column);

		} else {
		    // --- All validations done, rename the component and update the network model
			// --- renaming NetworkComponents and GraphElements
			this.getGraphController().getNetworkModelAdapter().renameNetworkComponent(oldCompID, newCompID);
		}
    }
}
// System.out.println(row+","+column);
  }
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:52,代碼來源:BasicGraphGuiRootJSplitPane.java

示例13: btnEliminarActionPerformed

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
    String codigo = ecod.getText();
    String apellido = eape.getText();
    String nombre = enom.getText();
    String direccion = edir.getText();
    String telefono = etel.getText();
    String colegiado = ecole.getText();
    if(codigo.length()==0||apellido.length()==0||nombre.length()==0||direccion.length()==0||telefono.length()==0||colegiado.length()==0)
    {
        JOptionPane.showMessageDialog(null, "Los registros no pueden estar vacios\nPor favor llene los registros", "Advertencia", JOptionPane.WARNING_MESSAGE);
        enom.requestFocus();
    }
    else
    {
        if(apellido.length()>50||nombre.length()>50||direccion.length()>50||telefono.length()>12||colegiado.length()>50)
        {
            JOptionPane.showMessageDialog(null, "El numero de caracteres en los registros es mayor al permitido\nNombre, Apellido, Direccion y Colegiado no pueden ser mayor a 50 caracteres\nTelefono no puede ser mayor a 12", "Advertencia", JOptionPane.WARNING_MESSAGE);
            enom.requestFocus();
        }
        else
        {
        int filasel;
        String id;
        filasel = tablaeliminar.getSelectedRow();
        if(filasel==-1)
        {
            JOptionPane.showMessageDialog(this, "Usted no ha seleccionado aún ninguna fila");
        }
        else
        {
            accion = 2;
            tablaEli = (DefaultTableModel) tablaeliminar.getModel();
            id = (String) tablaEli.getValueAt(filasel, 0); 
           Integer resp = JOptionPane.showConfirmDialog(this, "Esta a punto de eliminar los datos, \n\t¿desea continuar?", "Precaucion", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
           if(resp==0)
           {
               Medico m = new Medico(eape.getText(), enom.getText(), edir.getText(), etel.getText(), ecole.getText());
               Icon i = new ImageIcon(getClass().getResource("/Imagenes/Aceptar.jpg"));
               JOptionPane.showMessageDialog(null, m.EliminarMedico(m, ecod.getText()),"Mensaje",JOptionPane.INFORMATION_MESSAGE, i);
               Tabla t = new Tabla();
               t.LimpiarTabla(tablaEli);
               m.PresentarDatos(tablaEli);
               ecod.setText("");
               enom.setText("");
               eape.setText("");
               enom.setText("");
               edir.setText("");
               ecole.setText("");
               etel.setText("");
               aux.requestFocus();
           }
           else
           {
               JOptionPane.showMessageDialog(this, "Datos sin eliminar");
           }
        }
    
        }
    }
}
 
開發者ID:JuanJoseFJ,項目名稱:ProyectoPacientes,代碼行數:61,代碼來源:JDeliminar.java

示例14: editAction

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
 * 編輯
 */
private void editAction() {
    int selectedRow = fieldTable.getSelectedRow();
    if (selectedRow != -1) {
        DefaultTableModel tableModel = (DefaultTableModel) fieldTable.getModel();
        String oldFieldText = (String) tableModel.getValueAt(selectedRow, 0);
        String oldFieldTypeText = (String) tableModel.getValueAt(selectedRow, 1);
        String oldColumnText = (String) tableModel.getValueAt(selectedRow, 2);
        String oldColumnTypeText = (String) tableModel.getValueAt(selectedRow, 3);
        String oldSqlTypeText = (String) tableModel.getValueAt(selectedRow, 4);
        String oldColumnSizeText = (String) tableModel.getValueAt(selectedRow, 5);
        String oldCommentText = (String) tableModel.getValueAt(selectedRow, 6);

        ColumnEditDialog dialog = new ColumnEditDialog();
        dialog.setTitle("Edit a Column");

        dialog.getFieldTextField().setText(oldFieldText);
        dialog.getFieldTypeTextField().setText(oldFieldTypeText);
        dialog.getColumnTextField().setText(oldColumnText);
        dialog.getColumnTypeTextField().setText(oldColumnTypeText);
        dialog.getColumnSizeTextField().setText(oldColumnSizeText);
        dialog.getCommentTextField().setText(oldCommentText);

        dialog.getButtonOK().addActionListener(it -> {
            String fieldText = dialog.getFieldTextField().getText().trim();
            String fieldTypeText = dialog.getFieldTypeTextField().getText().trim();
            String columnText = dialog.getColumnTextField().getText();
            String columnTypeText = dialog.getColumnTypeTextField().getText().trim();
            String columnSizeText = dialog.getColumnSizeTextField().getText().trim();
            String commentText = dialog.getCommentTextField().getText().trim();

            tableModel.setValueAt(fieldText, selectedRow, 0);
            tableModel.setValueAt(fieldTypeText, selectedRow, 1);
            tableModel.setValueAt(columnText, selectedRow, 2);
            tableModel.setValueAt(columnTypeText, selectedRow, 3);
            tableModel.setValueAt(columnSizeText, selectedRow, 4);
            tableModel.setValueAt(commentText, selectedRow, 5);
            dialog.setVisible(false);
        });

        dialog.setSize(500, 260);
        dialog.setAlwaysOnTop(true);
        dialog.setLocationRelativeTo(this.$$$getRootComponent$$$());
        dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
        dialog.setResizable(false);
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        dialog.setVisible(true);

    }
}
 
開發者ID:hykes,項目名稱:CodeGen,代碼行數:53,代碼來源:TablePanel.java

示例15: jButton3ActionPerformed

import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    DefaultTableModel m = (DefaultTableModel)jTable1.getModel();
    int count = m.getRowCount();
    
    
    Random r = new Random();
    int index = r.nextInt(count--);
    System.out.print(index);
  
    String student = (String) m.getValueAt(index, 0);
    
    JOptionPane.showMessageDialog(rootPane, student);
    
    
}
 
開發者ID:karanjadhav2508,項目名稱:kqsse17,代碼行數:16,代碼來源:QuizResults.java


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