I am developing the application that contains the first window
appears after clicking on log in in the login window and the correct credentials After the selection is given to choose the time stamp and the Data Set ID window. It is such that I'm reaching the value of the API key ( I want to be successful log-user after any time data sets and time stamp can choose. Now it is to set up a connection using the API key Now I want to log in after any time I can click on the second button shown in this window and choose the time stamp and the Data Set ID. But in that situation I do not have the value of the API key because I am using it in Now after entering the correct access credentials in the user login window, how can it get the value of the API key stored in all the files and use it anywhere. Each file: login- java, algorithm.java, main java Jframe is expanding. And maine Java has the main () function which I am working in Netbeans 7.1.2. I'm coding it in Swing Java I'm new to Java. The fastest way to do this is to enter a global variable logged in. Java )
string value 1 = text 1.getText (); String value 2 = text 2.getText (); URL url = new URL ( "http: //website-link/method/user.json? UsernameName =" + value1 + "& amp; password =" + value2 "); HttpURL connection httpCon = (HttpURLConnection) url.openConnection ( ); BufferedReader = new BufferedReader (new InputStreamReader (HttpConkgetInputStream ())); string Inputlain; Stringbilder SB = new Stringbilder (); while ((InputLine = Inkreadline ())! = nULL) {sb.append ( inputLine);} string result; result = sb.toString (); string jsonSource = result; JSONArray array; try {array = new JSONArray (jsonSource); (int i = 0; i & lt; array.length () ; I ++) {JSONObject firstObject = (JSONObject) array.get (i); System.out.println ("APIkey" + first object .g etString ( "Apiki")); APIkey = firstObject.getString ( "apiKey");}
log Inkjawa
Algorithmkjawa passing a value (data set and to select the timestamp window)
if (httpCon .getResponseCode () == 200) {algorithm frame = new algorithm (APIIK); Frame.setSize (450,200); Frame.setVisible (true); Settlement (); JAlabelLabel = New JLabel ("Welcome:" + Value1); }
Algorithmkjawa and enter time certain, based on tickets and data set ID Selects the nodes.
main.java (responsible for the above window). And the value of the API key is empty in
MAJ.Java . I do not want the user to enter the login-in user name and password frequently.
if (e.getSource () == myFirstButton) {login frame1 = new login (); Frame1.setSize (450,200); Frame1.setVisible (true); } If (E. Gatesource () == mySecondButton) {algorithm frame = new algorithm (API); Frame.setSize (450,200); Frame.setVisible (true); }
APIKey
Main.Java and set the value of the user after logging in and if you do so, I will also add a logout button to unset this variable.
Comments
Post a Comment