Table not loading

2

I'm trying to make the table list load and not loading always gives this error

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem: 
The constructor PanelListClientes() is undefined

at view.FramePrincipal.listClientClicked(FramePrincipal.java:118)
at view.FramePrincipal$6.actionPerformed(FramePrincipal.java:94)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

My View Code is this

public class PanelListClientes extends JPanel {
private JTable table;

/**
 * Create the panel.
 */

public PanelListClientes(TableCliente tablecliente) {
    setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 181, 430, 108);
    add(scrollPane);

    table = new JTable();
    table.setModel(tablecliente);
    scrollPane.setViewportView(table);

    JButton btnCarregarTabela = new JButton("Carregar Tabela");
    btnCarregarTabela.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CarregarClicked(e);
        }
    });
    btnCarregarTabela.setBounds(267, 135, 142, 23);
    add(btnCarregarTabela);

}

protected void CarregarClicked(ActionEvent e) {
    ControleCliente cCliente = new ControleCliente();
    cCliente.constroiTabela();

}

The method that gives error is that of the main menu

protected void listClientClicked(ActionEvent e) {
    PanelListClientes plClientes = new PanelListClientes();
    this.setContentPane(plClientes);

}

    
asked by anonymous 20.11.2018 / 00:06

1 answer

2

The error is very clear. In this line:

PanelListClientes plClientes = new PanelListClientes();

You are trying to start the class with a parameterless constructor, but in its class PanelListClientes there is a constructor that expects a type TableCliente as a parameter.

In java, when you do not write a constructor for a class, you create a default constructor with no parameters you do not see, but it's there when the class is instantiated. From the moment you define a constructor, either with parameters or not, the compiler understands that you are taking responsibility for initializing the class and creating nothing.

To resolve, you must respect the constructor you created yourself, and pass the expected parameter, or create an alternative boot of your class with a constructor without a parameter.

    
20.11.2018 / 00:13