【初心者】Java質問・相談スレッド114【歓迎】at TECH
【初心者】Java質問・相談スレッド114【歓迎】 - 暇つぶし2ch316:デフォルトの名無しさん
08/04/14 13:04:35
間隔を置いて1文字ずつを流したいのですが、何十秒間表示なしで、突然いっきに文字列が出ます。
どうしたらいいんでしょう。ソースはこれです。
public void paint(Graphics g) {
Font font = new Font(null, Font.PLAIN, 30);
g.setFont(font);
FontMetrics metrics = g.getFontMetrics(font);
String text = "Get down on your knees. Beg for your life!";
int margin = 30;
int cx = margin, cy = 100, mx = getWidth() - margin;

for(int i = 0; i < text.length(); i++) {
g.drawString(String.valueOf(text.charAt(i)), cx, cy);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
System.out.println(e);
}
cx += metrics.charWidth(text.charAt(i));
if (cx > mx) {
cx = margin;
cy += metrics.getHeight();


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch