After much searching, I ended up arriving at the answer unintentionally.
I did this, I created a class PessoaPanelController
and established the PessoaPanel
in it, I called the @PostConstruct
and initialized all buttons on PessoaPanel
and now when I need PessoaPanel
me of the one @Autowired
in my component and use, but the real answer was @Scope("prototype")
which makes it so that every time I urge Personpanelcontroller the system creates a new separate instance and no one competes with anyone, follows below mine Controller
;
@Component
@Scope("prototype")
public class PessoaPanelController extends AbstractController {
@Autowired
public PessoaPanel frame;
@Autowired
private PessoaController pessoaController;
@Autowired
private PessoaService pessoaService;
public PessoaPanelController() { }
@PostConstruct
public void init() {
/********************************************************************************/
/** Pessoa ToolBar **************************************************************/
/********************************************************************************/
registerAction(this.frame.getBtnPessoaNovo(), new AbstractAction() {
protected void action() { frame.showPopupMenuPessoa(); }
});
registerAction(this.frame.getPopupMenu().getMnuPessoaNovoFisica(), new AbstractAction() {
protected void action() { pessoaController.show(); }
});
registerAction(this.frame.getBtnPessoaEditar(), new AbstractAction() {
protected void action() { pessoaEditar(); }
});
registerAction(this.frame.getBtnPessoaExcluir(), new AbstractAction() {
protected void action() { pessoaExcluir(); }
});
registerAction(this.frame.getBtnPessoaPesquisar(), new AbstractAction() {
protected void action() { refreshTablePessoa(); }
});
this.frame.getTablePessoa().addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent event) {
if(event.getClickCount() == 2) {
pessoaEditar();
}
}
});
this.frame.getTablePessoa().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
frame.getBtnPessoaEditar().setEnabled(true);
frame.getBtnPessoaExcluir().setEnabled(true);
}
});
}
public void refreshTablePessoa() {
this.frame.refreshTablePessoa(this.pessoaService.getAllPessoas());
}
public void pessoaEditar() {
Pessoa p = frame.getTablePessoa().getPessoaSelected();
if(p != null) {
this.pessoaController.show(p);
}
}
public void pessoaExcluir() {
Pessoa p = frame.getTablePessoa().getPessoaSelected();
if(p != null) {
int opcao = JOptionPane.showConfirmDialog(null,
"Confirma a exclusão deste(s) registro(s)?",
"Atenção",
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE);
if(opcao == 0) {
this.pessoaService.delete(p.getPessoaId());
}
}
}
public PessoaPanel getPanel() {
return frame;
}
}