How to access string in another class in Java - GUI : Another question for Java... I know it's basic, but I am not pro.

So I have Main.java

    public class Main {
    public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver", "C:/geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("https://my.emerchantpay.com/");
        eMerchantPay emp = PageFactory.initElements(driver, eMerchantPay.class);
        SwingUtilities.invokeLater(new Runnable() {
           public void run() {
                JFrame frame = new MainFrame("Please enter your credentials");
                frame.setSize(500, 400);
                //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
           }
        });
        
        emp.uid(username);
        emp.pwd(password);
        emp.LoginButton.click();

And the string is located in DetailsPanel.java

    public class DetailsPanel  extends JPanel{
    
    private static final long serialVersionUID = 1234567891;
    
    private EventListenerList listenerList = new EventListenerList();
    
    public DetailsPanel() {
        Dimension size = getPreferredSize();
        size.width = 250;
        setPreferredSize(size);
        
        setBorder(BorderFactory.createTitledBorder("Personal Details"));
        
        JLabel nameLabel = new JLabel("Name: ");
        JLabel passwordLabel = new JLabel("Password: ");
        
        final JTextField nameField = new JTextField(10);
        final JPasswordField passwordField = new JPasswordField(10);
        
        final JButton addBtn = new JButton("Submit");
        
        addBtn.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                String name = nameField.getText();
                String password = passwordField.getText();
                
                String text = name + ": " + password + "\n";
                JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(addBtn);
                frame.dispose();
                System.out.println (text);
            }
        });
        
        setLayout(new GridBagLayout());
        
        GridBagConstraints gc = new GridBagConstraints();
        
        /// First column ///
        gc.anchor = GridBagConstraints.LINE_END;
        gc.weightx = 0.5;
        gc.weighty = 0.5;
        
        gc.gridx = 0;
        gc.gridy = 0;
        add(nameLabel, gc);
        
        gc.gridx = 0;
        gc.gridy = 1;
        add(passwordLabel, gc);
        
        /// Second column ///
        gc.anchor = GridBagConstraints.LINE_START;
        
        gc.gridx = 1;
        gc.gridy = 0;
        add(nameField, gc);
        
        gc.gridx = 1;
        gc.gridy = 1;
        add(passwordField, gc);
        
        /// Final row ///
        gc.weighty = 10;
        
        gc.anchor = GridBagConstraints.FIRST_LINE_START;
        
        gc.gridx = 1;
        gc.gridy = 2;
        add(addBtn, gc);
    }
    
    public void fireDetailEvent(DetailEvent event) {
        Object[] listeners = listenerList.getListenerList();
        
        for (int i=0; i < listeners.length; i += 2) {
            if (listeners[i] == DetailListener.class) {
                ((DetailListener)listeners[i+1]).detailEventOccured(event);
            }
        }
    }
    
    public void addDetailsListener(DetailListener listener) {
        listenerList.add(DetailListener.class, listener);
    }
    
    public void removeDetailListener(DetailListener listener) {
        listenerList.remove(DetailListener.class, listener);
        
    }
So the strings are located here 

String name = nameField.getText();

String password = passwordField.getText();

How do I access these from Main.java? I have to assign the name value to emp.uid(username);

Thank you in advance!!!