I need a simple way to make Methods that can be used in a JLabel. I want to make a .write(some text); Method that whenever I call jLabel.write(some text); it writes out some text letter by letter. I can easily do this with the console, but I do now know how to do it in a JLabel.
Example Code:
public void write(String a) {
char letter;
String word = "";
for(int i = 0; i < a.length(); i++) {
letter = a.charAt(i);
this.setText(word + letter);
word = word + letter;
try {
Thread.sleep(100);
} catch(Exception e) {
}
}
}
...
text.write("Hello");
For obvious reasons this does not work. But is there any way to make it?