Question: I have two JFrames `login.java` and `account.java`   

I need to get the `username` from the `login.java` page and put it in a variable in the `account.java` `JFrame`. How can I do this in the Java NetBeans using the Swing?

Answer: 
Instead of Using JFrames for passing values between different forms you can use CardLayout which will persist your data which you have entered in the previous form.
All you have to do is Create a JFrameForm and add panels to it.
The 100% working solution. Suppose u r calling welcome.java

```
Account ac= new Account(new JFrame(), true);

```

After this line call a method of welcome.java which u have to create like:

```
wc.setUser(username);

```

For account.java

```
create a method:void setUser(String username) {
        user1 = user; 
        cname.setText(user1);
    }

```

User1 is global variable and available for all which u have to define lke:

```
String user1;

```

after it is assigning the username value to user1. here cname is a label which name is cname; so, we are seeting the text of cname to the user.