jeudi 14 janvier 2021

How to set the value of a jTextField from separate class (Java Swing)

I'm trying to implement the facade design pattern into my application by using Java swing on Netbeans.
But when I click button1 on the GUI, nothing happens. I'm not getting any errors either.

Here is my code:

public interface signupinterface {
    // will be used for facade pattern
    void signupM();
}

My suspicion is that the issue is with the signupClearall class. Setting the value for a jTextField from a separate class that is not the Jframe GUI class. I set the text fields to public static as well, but no luck here.

public class signupClearall implements signupinterface {
                        
    @Override
    public void signupM() {
        signup.jTextField1.setText("");
        signup.jTextField2.setText("");
        signup.jTextField3.setText("");
        signup.jPasswordField1.setText("");
        signup.jPasswordField1.setText("");
}

public class signupFacade {
   
    private signupinterface clear;
   
    public signupFacade() {
        clear = new signupClearall();
    }
   
    public void getClearall(){
        clear.signupM();
    }
}
  
// THIS IS THE JFRAME GUI CLASS
// there are more here autogenerated code here from the IDE, but I just placed the action performed

public class signup extends javax.swing.JFrame{
       
signupFacade signupFacade1 = new signupFacade();
                     
    // Removes all information that have currently been entered
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        signupFacade1.getClearall();
    }   
}

I'm sorry if this is a stupid question. I'm stumped on this one.

Aucun commentaire:

Enregistrer un commentaire