2

I have login.java then i need to pass the username from the login.java to nursepage.java then pass one more time to updatestatus.java so how do i pass the value for three times?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
James
  • 21
  • 2
  • this mey help (https://stackoverflow.com/questions/9834915/how-to-pass-a-variable-value-from-one-jframe-to-another-jframe-in-netbeans) – guleryuz Apr 22 '18 at 04:59
  • 1
    1) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) 2) Please learn common Java nomenclature (naming conventions - e.g. `EachWordUpperCaseClass`, `firstWordLowerCaseMethod()`, `firstWordLowerCaseAttribute` unless it is an `UPPER_CASE_CONSTANT`) and use it consistently. 3) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Apr 22 '18 at 05:15

1 Answers1

0

Well, you simply could use some kind of static method-call-chain. e.g.

Updatestatus.java

private String username;

public static void setUsername(String username){
    this.username = username;
}

Nursepage.java

import Updatestatus;

public static void setUsername(String username){
    Updatestatus.setUsername(username);
}

Login.java

import Nursepage;

private String username;

private static void provideUsername(){
   Nursepage.setUsername(username);
}

Set your username locally in Login.java, then call the provideUsername()-method. The username will now be provided down to Updatestatus.java.