📜  如何在 jaca 中制作打字机效果 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:28.243000             🧑  作者: Mango

代码示例1
String text = "hello world";
int i;
for(i = 1; i <= text.length(); i++){
    g.drawString(text.subString(0, i), x, y);//Where g is your Graphics object and x and y are the coordinates you want to draw at
    try{
        Thread.sleep(500);//0.5s pause between characters
    }catch(InterruptedException ex){
        Thread.currentThread().interrupt();
    }
}