How to draw text to screen - when text are tweets using a particular hashtag?

edited January 2018 in Library Questions

Hi there - beginner here

I am working on a project where I aim to visualise tweets of a certain hashtag. I am using Processing 3 with Twitter4j. I am able to get the tweets to show up in the console but not in a sketch. I understand I need to use text() as well as setting a font before this but I am confused as to what the data or string data is supposed to be in text() in this particular case

Examples of text() being used I usually see a word or a sentence, but in this case I need it to be the tweets that use this particular hashtag that I have set in the string keywords.

Ultimately I don't want to just display text in the sketch but also some lines and colour and pretty visuals etc. but right now I am stuck on this!

Any help would be really very much appreciated!


  • fill(255);

    text( tweet, 111,111);

    Does that work?

    Not sure what’s the problem...

    Can you show your code?

  • Hey thanks for your response - when I put that in it gives the message "tweet cannot be resolved to a variable" - will show the code

  • edited January 2018
    TwitterStream twitterStream;
    ArrayList<String> words = new ArrayList();
    void setup() {     
      size(500, 500);
      background(255, 47, 0); 
      createFont("Arial", 24);
    void draw() {     
      background(255, 47, 0);
      text(words, 111, 111);
        void openTwitterStream() {  
          ConfigurationBuilder cb = new ConfigurationBuilder();  
          TwitterStream twitterStream = new TwitterStreamFactory(;
          FilterQuery filtered = new FilterQuery();
          String keywords[] = {
          if (keywords.length==0) {
            twitterStream.sample(); // and calls these adequate listener methods continuously.
          else { 
        StatusListener listener = new StatusListener() {
          public void onStatus(Status status) {
            System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
          public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
            System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
          public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
            System.out.println("Got track limitation notice:" + numberOfLimitedStatuses);
          public void onScrubGeo(long userId, long upToStatusId) {
            System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
          public void onStallWarning(StallWarning warning) {
            System.out.println("Got stall warning:" + warning);
          public void onException(Exception ex) {
  • edited January 2018

    tweet was just an example of course

    this seems to be the great line:

      System.out.println("@" + status.getUser().getScreenName() + " - " +       status.getText());

    so you want something like:

    String tweet = "@" + status.getUser().getScreenName() + " - " +       status.getText(); 
    text(tweet, 111,111); 

    after line 55

    Write line and line after each other

    to write line and line after each other, place String tweet=""; before setup() and then say :

    // adding up the tweets (because of += and without "String ")
    tweet += "@" + status.getUser().getScreenName() + " - " +       status.getText() +"\n"; 
    text(tweet, 111,111, 300, 700);  // display with line break in a box 

    not tested

Sign In or Register to comment.