本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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();
}
示例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);
}
示例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");
}
}
}
}
}
示例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);
}
}
示例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);
}