I run another jFrame’s method, but doesn’t it add to the list?

Asked

Viewed 22 times

-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);
}

inserir a descrição da imagem aqui That’s what I need to do.

  • 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.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.