We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have my programme here, where you can see I have a string called "S", and a void Get Temperature. At the bottom where keypresses are processed, it has an else If statement with ENTER. I want it so that when you press enter, it updates the string (s) to whatever you have typed, and then load it into the "SetAddress" field. How would I go about this?
    import com.temboo.core.*;
    import com.temboo.Library.Yahoo.Weather.*;
    import ddf.minim.*;
    AudioPlayer player;
    Minim minim;
    PImage bg;
    String myText;
    PFont Bold;
    PFont Thin;
    TembooSession session = new TembooSession("goldsmiths-c", "myFirstApp", "CNgLbwqnqzGdsnk6wHXPfAnQNSmV0Fmr");
    String s = "London";
    int prev = frameCount;
    //KeyPressed KeyPressed = new KeyPressed();
    void setup() {
      size(960, 540);
      bg = loadImage("mountains.jpg");
      minim = new Minim(this);
      player = minim.loadFile("song.mp3");
      player.play();
      player.loop();
      runGetTemperatureChoreo(); 
      Bold = createFont ("TTFirsBlackItalic.otf", height);
      Thin = createFont ("TTFirsThin.otf", height);
      frameRate (10);
    }
    void draw() {
      background(bg);
      fill (0);
      textFont (Bold);
      textSize (48);
      fill(255, 255, 255);
      text(myText, 10, 390);
      fill(255, 255, 255);
      textFont (Thin);
      textSize (48);
      text(s, 10, 500);
      print(mouseY);
    }
    void runGetTemperatureChoreo() {
    loop();
      GetTemperature getTemperatureChoreo = new GetTemperature(session);
      getTemperatureChoreo.setAddress(s);
      getTemperatureChoreo.setUnits("c");
      GetTemperatureResultSet getTemperatureResults = getTemperatureChoreo.run();
      myText = (s) + (getTemperatureResults.getTemperature() + ("°c"));
      print(getTemperatureResults.getTemperature());
    }
    void keyPressed()
    {
      if (keyPressed && prev <= frameCount-10) { //If a key is being pressed, and the security/delay is fine with it
        prev = frameCount; //re-Init the clock
        if (keyCode == BACKSPACE) { //Delete a char!
          if (s.length() > 0) {
            s = s.substring(0, s.length()-1);
          }
        } else if (keyCode == DELETE) {
          s = "";
        } else if (keyCode == ENTER && s.length() != 0) {
          s += key;
        } else if (keyCode != SHIFT && keyCode != CONTROL && keyCode != ALT && s.length() < 20) { //It's an ok char, add it to the String
          s += key;
        }
      }
    }
Answers
https://www.Reddit.com/r/processing/comments/4f5y5y/how_to_make_keycode_enter_update_string/
I'm the same person, with a question? Is that against the rules or something?
I was just informing both sides that this is a cross-site post.
So folks from the other side can see what's going on here too. O:-)
Nonetheless, here's an online example about text box: ;;)
http://studio.ProcessingTogether.com/sp/pad/export/ro.9Zo$UbIWYZEDR
I don't think my problem is a text box, I think my problem is finding a way of updating .setAddress(S) when the programme is already running. It updates when I load the programme, but it need it to update when I click, or press enter etc..
You may consider showConfirmDialog() from class JOptionPane:
http://docs.Oracle.com/javase/8/docs/api/javax/swing/JOptionPane.html#showConfirmDialog-java.awt.Component-java.lang.Object-
Some forum threads about it:
https://forum.Processing.org/two/discussions/tagged?Tag=showconfirmdialog()
A more refined approach is having a Button to click at: *-:)
http://studio.ProcessingTogether.com/sp/pad/export/ro.9eDRvB4LRmLrr
Some forum threads about it as well:
https://forum.Processing.org/two/discussions/tagged/buttons
This still doesn't really help me, because my problem is getting it to update, not creating a way for it to update