Skip to content

Instantly share code, notes, and snippets.

@PaulBGD
Forked from DarkBlade12/ScrollingString.java
Last active December 26, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulBGD/7064922 to your computer and use it in GitHub Desktop.
Save PaulBGD/7064922 to your computer and use it in GitHub Desktop.
Smaller
public class ScrollingString {
private String original;
private int position;
public ScrollingString(String original) {
this.original = original;
}
public void scroll() {
position++;
if (position == original.length())
position = 0;
}
public String getScrolledString() {
int e = position + original.length();
return e > original.length() ? original.substring(position, original.length()) + original.substring(0, width - (original.length() - position)) : original.substring(position, e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment