当前位置: 首页>>代码示例>>Java>>正文


Java DefaultTableModel.addRow方法代码示例

本文整理汇总了Java中javax.swing.table.DefaultTableModel.addRow方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTableModel.addRow方法的具体用法?Java DefaultTableModel.addRow怎么用?Java DefaultTableModel.addRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.table.DefaultTableModel的用法示例。


在下文中一共展示了DefaultTableModel.addRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listarItens

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public void listarItens() {
    final String sql = ("SELECT * FROM item WHERE fk_personagem = (?)");
    try {
        PreparedStatement stmt = c.prepareStatement(sql);
        stmt.setInt(1, pegarPk_personagem(nomePersonagem));
        ResultSet rs = stmt.executeQuery();
        DefaultTableModel model = (DefaultTableModel) TelaEquipamentos.tabela.getModel();
        while (rs.next()) {
            int id = rs.getInt("pk_item");
            String nomeIcon = rs.getString("icone_ite");
            ImageIcon icon = (new ImageIcon(getClass().getResource("/ItemIcons/" + nomeIcon)));
            String nome = rs.getString("nome_ite");
            String atibutos = rs.getString("atributos_ite");
            String descricao = rs.getString("descricao_ite");
            int quantidade = rs.getInt("quantidade_ite");
            Object[] item = {id, quantidade, icon, nome, null, atibutos, descricao};
            model.addRow(item);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:lucas-dolsan,项目名称:tcc-rpg,代码行数:24,代码来源:DAO.java

示例2: loadTableBD

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public void loadTableBD() {
    Result res = db.execute("MATCH (n:`Vol`) RETURN n.numero, n.villeDep, n.villeArr, n.heureDep, n.heureArr, n.distance, n.frequence ORDER BY n.numero");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"n.numero", "Depart", "Arrivee", "Heure Depart", "Heure Arrivee", "Distance", "Frequence"};
    String test[] = {"n.numero", "n.villeDep", "n.villeArr", "n.heureDep", "n.heureArr", "n.distance", "n.frequence"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }
        
        dtm.addRow(obj.values().toArray());
}
}
 
开发者ID:ATF19,项目名称:flight-management-system-java,代码行数:21,代码来源:AfficherVols.java

示例3: setHandsAndBallsTableSize

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
final private void setHandsAndBallsTableSize() {

		final int intLballsPreviousNumber = this.intGballsNumber;

		this.intGballsNumber =
								Math.max(	0,
											this.objGjuggleMasterPro.objGsiteswap == null
												|| this.objGjuggleMasterPro.objGsiteswap.bytGstatus <= Constants.bytS_STATE_SITESWAP_UNKNOWN_BALLS_NUMBER
																																							? 0
																																							: this.objGjuggleMasterPro.objGsiteswap.intGballsNumber);
		if (this.intGballsNumber != intLballsPreviousNumber) {
			final DefaultTableModel objLdefaultTableModel = (DefaultTableModel) this.objGhandsAndBallsJTable.getModel();
			if (this.intGballsNumber > intLballsPreviousNumber) {
				for (int intLballIndex = intLballsPreviousNumber; intLballIndex < this.intGballsNumber; ++intLballIndex) {
					objLdefaultTableModel.addRow(new String[DataJFrame.bytS_HANDS_AND_BALLS_TABLE_COLUMNS_NUMBER]);
				}
			} else {
				for (int intLballIndex = intLballsPreviousNumber; intLballIndex > this.intGballsNumber; --intLballIndex) {
					objLdefaultTableModel.removeRow(intLballIndex + 1);
				}
			}
		}
	}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:24,代码来源:DataJFrame.java

示例4: loadTableBD

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public void loadTableBD(int cin) {
    Result res = db.execute("MATCH (n:`Personnel`{cin:"+cin+"}) RETURN n.cin, n.numPassport, n.nom, n.adresse, n.telephone, n.type");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Cin", "Passport", "Nom", " Adresse", "Telephone", "Type"};
    String test[] = {"n.cin", "n.numPassport", "n.nom", "n.adresse", "n.telephone", "n.type"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }
        
        dtm.addRow(obj.values().toArray());
}
}
 
开发者ID:ATF19,项目名称:flight-management-system-java,代码行数:21,代码来源:AfficherEmployees.java

示例5: listarArmasMon

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public void listarArmasMon() {
    final String sql = ("SELECT * FROM itemWeapon WHERE fk_personagem = (?)");
    try {
        PreparedStatement stmt = c.prepareStatement(sql);
        stmt.setInt(1, pegarPk_personagem(nomePersonagem));
        ResultSet rs = stmt.executeQuery();
        DefaultTableModel model = (DefaultTableModel) TelaMonstro.tabela.getModel();
        while (rs.next()) {
            int id = rs.getInt("pk_itemWeapon");
            String nomeIcon = rs.getString("icone_itWea");
            ImageIcon icon = (new ImageIcon(getClass().getResource("/WeaponIcons/" + nomeIcon)));
            String nome = rs.getString("nome_itWea");
            int dano = rs.getInt("danoBase_itWea");
            String atibutos = rs.getString("atributos_itWea");
            String descricao = rs.getString("descricao_itWea");
            int quantidade = rs.getInt("quantidade_itWea");
            Object[] arma = {id, quantidade, icon, nome, dano, atibutos, descricao};
            model.addRow(arma);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:lucas-dolsan,项目名称:tcc-rpg,代码行数:25,代码来源:DAO.java

示例6: populatetable

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
/**
 * Loads the Data Array into the tmodel with custom datatype
 *
 * @param table to be populated
 * @param header column header
 * @param rows nullRoww data
 * @return populated tmodel
 */
public static void populatetable(JTable table, List<String[]> rows) {
    removeRowSelection(table);
    DefaultTableModel tablemodel = (DefaultTableModel) table.getModel();
    table.setRowSorter(null);
    tablemodel.setRowCount(0);
    for (String[] row : rows) {
        int colsize = row.length;
        Object[] newRow = new Object[colsize];
        for (int col = 0; col < colsize; col++) {
            newRow[col] = col > 0 ? row[col] : Boolean.valueOf(row[0]);
        }
        tablemodel.addRow(newRow);
    }
    table.setModel(tablemodel);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:24,代码来源:JtableUtils.java

示例7: populatePostPayTable

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void populatePostPayTable(DefaultTableModel model) {

		// import all customers from database
		final PostingDaoImpl postingDaoImpl = new PostingDaoImpl();
		List<Posting> postingList = postingDaoImpl.getAllPostingsByRoomNumber(roomNumber, hotelSystemStatus.getDateTime().toString());

		final PaymentDaoImpl paymentDaoImpl = new PaymentDaoImpl();
		List<Payment> paymentlist = paymentDaoImpl.getAllPaymentsByRoomNumber(roomNumber, hotelSystemStatus.getDateTime().toString());

		// clean table model
		model.setRowCount(0);

		for (Posting pos : postingList) {

			model.addRow(new Object[] { pos.getId(), pos.getPostType(), pos.getTitle(), pos.getPrice(),
					pos.getCurrency(), pos.getExplanation(), pos.getDateTime() });
		}

		for (Payment pay : paymentlist) {

			model.addRow(new Object[] { pay.getId(), pay.getPaymentType(), pay.getTitle(), pay.getPrice(),
					pay.getCurrency(), pay.getExplanation(), pay.getDateTime() });
		}
	}
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:25,代码来源:RoomWindow.java

示例8: Soru1

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public Soru1() {
    initComponents();

    ///SORGULAMA
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("BP2_LAB2PU");
    EntityManager em = emf.createEntityManager();

    Query q = em.createQuery("SELECT d FROM Doktor d");
    doktorlar = q.getResultList();
    for (Doktor dr : doktorlar) {
        cmb_doktorlar.addItem(dr.getAdi() + " " + dr.getSoyadi());
    }

    dtm = new DefaultTableModel();
    dtm.setColumnIdentifiers(new Object[]{"ID", "ADI", "SOYADI", "DOkTOR ID"});
    q = em.createQuery("SELECT h FROM Hasta h");
    List<Hasta> hastalar = q.getResultList();
    for (Hasta hs : hastalar) {
        dtm.addRow(new Object[]{hs.getId(), hs.getAdi(), hs.getSoyadi(), hs.getIdDoktor()});
    }
    tbl_hastalar.setModel(dtm);
    /////
}
 
开发者ID:sametkaya,项目名称:Java_Swing_Programming,代码行数:24,代码来源:Soru1.java

示例9: produtoAdicionar

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void produtoAdicionar(){
    DefaultTableModel model = (DefaultTableModel) jTableProdutos.getModel();
    model.addRow(new Object[]{
        model.getRowCount()+1,
        jTextFieldProdutoCodigo.getText() + " - " + jTextFieldProdutoNome.getText(),
        Generica.stringConverterParaFloat(jFormattedTextFieldProdutoQuantidade.getText()),
        Generica.stringConverterParaFloat(jFormattedTextFieldProdutoValorUnitario.getText()),
        Generica.stringConverterParaFloat(jFormattedTextFieldProdutoValorTotal.getText())});
    
    jTextFieldProdutoCodigo.setText("");
    jTextFieldProdutoNome.setText("");
    jFormattedTextFieldProdutoQuantidade.setText("");
    jFormattedTextFieldProdutoValorUnitario.setText("");
    jFormattedTextFieldProdutoValorTotal.setText("");
}
 
开发者ID:iuryamicussi,项目名称:TrabalhoCrisParte2,代码行数:16,代码来源:ManutencaoEntradaEstoque2.java

示例10: configProxyActionPerformed

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void configProxyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configProxyActionPerformed
    DefaultTableModel model = (DefaultTableModel) driverPropTable.getModel();
    model.addRow(new Object[]{"useProxy", "true"});
    model.addRow(new Object[]{"proxyHost", "proxy.xx.com"});
    model.addRow(new Object[]{"proxyPort", "5656"});
    model.addRow(new Object[]{"proxyUserDomain", "xyz"});
    model.addRow(new Object[]{"proxyUser", "username"});
    model.addRow(new Object[]{"proxyPassword", "[email protected]"});
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:10,代码来源:DriverSettings.java

示例11: MostrarTablapaceintes

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public String MostrarTablapaceintes(DefaultTableModel Modelo,String apellido){
     Conexion nuevaConexion = new Conexion();
      Connection conex;
      ResultSet Consulta = null;
      try {
        nuevaConexion.Conectar();
        conex = nuevaConexion.getConexion();
          Statement comando = conex.createStatement();
         
          Consulta = comando.executeQuery("select pacientes.idPaciente,pacientes.Nombre, pacientes.Apellidos, pacientes.DIreccion, pacientes.Telefono from pacientes where pacientes.Apellidos='"+apellido+"'");
           String pacientes[] = new String[5];
          while(Consulta.next()==true){
              pacientes[0]=Consulta.getString("idPaciente");
                pacientes[1]=Consulta.getString("Nombre");
           pacientes[2]=Consulta.getString("Apellidos");
            pacientes[3]=Consulta.getString("DIreccion");
             pacientes[4]=Consulta.getString("Telefono");
             Modelo.addRow(pacientes);
             
          }
          
          {
            JDeditarpaciente.jtmostrarpacientes.setModel(Modelo);
            return"tabla llena";
          }
         
    } catch (Exception e) {
          JOptionPane.showMessageDialog(null,"error"+ e);
          return "error";
    }
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:32,代码来源:tablapacientes.java

示例12: readJTable

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public void readJTable() {
    DefaultTableModel modelo = (DefaultTableModel) TabelaQuestoes.getModel();
    modelo.setNumRows(0);
    QuestaoDAO qdao = new QuestaoDAO();

    for (Questao q : qdao.read()) {
        modelo.addRow(new Object[]{
            q.getId(), q.getNome(), q.getEnunciado(), q.getEntrada1(), q.getEntrada2(), q.getEntrada3(), q.getSaida1(), q.getSaida2(), q.getSaida3()
        });
    }

}
 
开发者ID:carlinhosxxp,项目名称:RhydoJudge,代码行数:13,代码来源:GerenciarQuestoes.java

示例13: loadFileinTable

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public static void loadFileinTable(File file, JTable table) {
    if (file.exists()) {
        try (Reader in = new FileReader(file)) {
            CSVParser parser = CSVFormat.EXCEL.withHeader().withSkipHeaderRecord().withIgnoreEmptyLines().parse(in);
            if (!parser.getHeaderMap().isEmpty()) {
                DefaultTableModel model = (DefaultTableModel) table.getModel();
                for (String columnHeader : parser.getHeaderMap().keySet()) {
                    if (!columnHeader.trim().isEmpty()) {
                        model.addColumn(columnHeader);
                    }
                }
                List<CSVRecord> records = parser.getRecords();
                for (CSVRecord record : records) {
                    Object[] row = new Object[record.size()];
                    for (int i = 0; i < record.size(); i++) {
                        row[i] = record.get(i);
                    }
                    model.addRow(row);
                }
            }
        } catch (IOException ex) {
            LOGGER.log(Level.SEVERE, null, ex);
        }
    } else {
        LOGGER.log(Level.SEVERE, "File [{0}] doesn''t exist", file.getAbsolutePath());
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:28,代码来源:FileUtils.java

示例14: MaasHesap

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public MaasHesap() {
    initComponents();
    dtm= new DefaultTableModel();
    dtm.setColumnIdentifiers(new Object[]{"ADI","SOYADI","MAAS"});
    dtm.addRow(new Object[]{"Ali","Kara","1000"});
     dtm.addRow(new Object[]{"Ali","Kara","1000"});
      dtm.addRow(new Object[]{"meryem","uzer","5000"});
    tbl_liste.setModel(dtm);
    
}
 
开发者ID:sametkaya,项目名称:Java_Swing_Programming,代码行数:11,代码来源:MaasHesap.java

示例15: setupDevicesTable

import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void setupDevicesTable() {
    DefaultTableModel tableModel = (DefaultTableModel) devicesTable.getModel();
    tableModel.setRowCount(0);
    for (IDevice device : devices) {
        String name;
        String target;
        if (device.isEmulator()) {
            name = device.getAvdName();
            AvdInfo info = avdManager.getAvd(device.getAvdName(), true /*validAvdOnly*/);
            target = info == null ? "?" : device.getAvdName();
        } else {
            name = "N/A";
            String deviceBuild = device.getProperty(IDevice.PROP_BUILD_VERSION);
            target = deviceBuild == null ? "unknown" : deviceBuild;
        }
        String state;
        if (DeviceState.BOOTLOADER.equals(device.getState())) {
            state = "bootloader";
        } else if (DeviceState.OFFLINE.equals(device.getState())) {
            state = "offline";
        } else if (DeviceState.ONLINE.equals(device.getState())) {
            state = "online";
        } else {
            state = "unknown";
        }

        tableModel.addRow(new Object[]{
            // TODO nulls?
            device.getSerialNumber(), name, target,
            Boolean.valueOf("1".equals(device.getProperty(IDevice.PROP_DEBUGGABLE))),
            state
        });
    }
    devicesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            DeviceUiChooser.this.updateState();
        }
    });
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:41,代码来源:DeviceUiChooser.java


注:本文中的javax.swing.table.DefaultTableModel.addRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。