E sono pienamente d'accordo con te.
Ma secondo te quello che ti sto per esporre potrebbe essere una soluzione.
Nel frame principale, cliccando un bottone creo il frame secondario, al cui costruttore passo il frame principale e il panel contenuto in quest'ultimo.
Se nel panel implemento un metodo che mi fa il refresh di quello che mi occorre, posso richiamare questo metodo nel frame secondario?
Metto il codice. Questo è quello presente nel frame principale:
codice:
private void editProfileActionPerformed(java.awt.event.ActionEvent evt) {
EditUser_JFrame editUser = new EditUser_JFrame(firstFrame, this);
editUser.setVisible(true);
}
public void refreshPanel(Contact c){
//Devo fare il refresh
telContact.setText(c.getTel());
sedeContact.setText(c.getLocation());
...
}
e nel frame secondario ho
codice:
public class EditUser_JFrame extends javax.swing.JFrame {
private static JFrame firstFrame = null;
private static JPanel firstPanel = null;
/** Creates new form User_JFrame */
public EditUser_JFrame(JFrame frame, JPanel panel) {
firstFrame = frame;
firstPanel = panel;
initComponents();
....
}
private void save_buttonActionPerformed(java.awt.event.ActionEvent evt) {
try {
.....
firstPanel.refreshPanel(contact );
....
}
catch(){
.......
}
Ma mi dà errore su lla chiamata al metodo refreshPanel(contact)...perchè?