I been trying to do “the question title”. Here is my current code:
Main.java
import java.awt.*;
import javax.swing.*;
public class Main {
public static void main(String[] args) {
JFrame f= new JFrame ("My Frame");
f.setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE);
JTabbedPane tp = new JTabbedPane();
User user = new User();
tp.addTab("Register", new Register(user));
tp.addTab("Process", new Process(user));
f.add(tp);
f.pack();
f.setVisible(true);
}
}
Register.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Register extends JPanel {
/*
The code too long, but what this class does is, display textfields:
username, password and email address
And there is a submit button, when press, it will update the process pane
*/
}
How to pass the username password and email to Process.java(Jpanel)?
[I am new to java and no programming background]
As I can see, you share
userbetweenRegisterandProcess. So the problem is how to refreshProcesswhen data inuserare updated. You could create listener onUser, or on ‘Register’. IMHO listener on ‘Register’ is more elegant.RegisterListener:
Register:
Process:
And in main:
So Process should be informed when user is registered, and it should receive all the necessary data in
userparameter of listener method.