-1
Good morning !
I need to know how to fill a table with data from another jFrame. I created a function in the Viewpedido class that fills the table, but when I run it through another frame, it doesn’t work. Maybe it’s the "new" that I pass when I urge, there’s a way I can do it without the "new"?
This function I run in jFrame Addpizza if I add a "request.setVisible(true)" it works, but creates another frame
public void adicionarPizza() {
DefaultTableModel modelo = (DefaultTableModel) tb_pizza.getModel();
int linha = tb_pizza.getSelectedRow();
Object[] pizza = {
combo_qtd.getSelectedItem(),
modelo.getValueAt(linha, 1),
modelo.getValueAt(linha, 2)
};
ViewPedido pedido = new ViewPedido();
pedido.addTeste(pizza);
}
This or function is in jFrame Viewpedido
public void addTeste(Object[] pizza) {
DefaultTableModel modelo = (DefaultTableModel) tb_pedido.getModel();
modelo.addRow(pizza);
}
Hello, could you put your code inside the question, textual? It is not necessary to remove the image, but it is important to have the essential parts of your source code in the body of the question. Learn why it’s not cool to put pictures in questions Post Error Message as Picture. One of the reasons is that if someone wants to answer the question, they cannot copy and execute their code. Images do not play well in search engines because content cannot be indexed.
– Danizavtz