Java JTable not showing up

Viewed 125

I'm trying to show the data into the Jtable, my AbstractTableModel class works fine and the table works in another gui but in this case is not working at all. I put the JTable inside the scrollPane but still does not work

public Eliminar_Cliente() {
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 452, 223);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(null);
    setContentPane(contentPane);


    JLabel lblEscribaElId = new JLabel("Escriba el ID del Usuario");
    lblEscribaElId.setBounds(150, 11, 115, 14);
    contentPane.add(lblEscribaElId);

    Search_Field = new JTextField();
    Search_Field.setBounds(150, 36, 115, 20);
    contentPane.add(Search_Field);
    Search_Field.setColumns(10);

    JButton Eliminar = new JButton("Eliminar");
    Eliminar.setBounds(97, 137, 89, 23);
    contentPane.add(Eliminar);

    JButton Cancelar = new JButton("Cancelar");
    Cancelar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            dispose();
        }
    });
    Cancelar.setBounds(235, 137, 89, 23);
    contentPane.add(Cancelar, BorderLayout.EAST);

    Search_Button = new JButton("Buscar");
    Search_Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {


            try {
                String ID = Search_Field.getText();
                List<Getters> list = null;
                if(ID != null && ID.trim().length() > 0)
                {

                    list = MA.searchClientID(ID);
                    TableCol model = new TableCol(list);
                    table.setModel(model);
                }
                else
                {
                    ERROR_GUI ER =new ERROR_GUI();
                    ER.setVisible(true);
                }

            }catch(Exception ex)
            {
                ex.printStackTrace();
            }

        }
    });
    Search_Button.setBounds(275, 35, 89, 23);
    contentPane.add(Search_Button, BorderLayout.SOUTH);

    scrollPane = new JScrollPane();
    scrollPane.setBounds(429, 67, -425, 14);
    contentPane.add(scrollPane);

    table = new JTable();
    scrollPane.setViewportView(table);
    table.setFillsViewportHeight(true);
}

when i click the button for testing all the information displayed in the console so it seems that it works but i am unable to display it in the JTable.

1 Answers

this is referring to current Jframe

this.add(new JScrollPane(table));
this.pack();
this.setVisible(true);
Related