밑에 코드에서 f.repaint()를 호출하든 안하든 똑같은 결과가 나오는데요...
repaint()를 호출 안해도 제대로 출력되는 이유가...
걍 자동적으로 repaint()가 호출되서 그런건가요?
책에서
AWT쓰레드에 의해 자동적으로 화면이 갱신되는 상황은
1. 처음 화면에 나타날 때
2. 다른 화면에 가려져 있던 부분이 다시 화면에 나타날 때
3. 아이콘화 되어 있다가 원래 크기로 화면에 나타날 때
라고 되어있는데요, Frame의 타이틀(여기서는 시간이죠)이 바뀌는게 저 3가지에 들어가지는 않는거같아서요..
/*
* 타이틀 바에 현재 시간을 출력하는 시계를 작성하는 예제입니당.
* 쓰레드를 이용해서 1초마다 변경되도록 할거에요.
* SimpleDateFormat을 사용할거에요.
*/ import java.text.SimpleDateFormat; import java.util.*; import java.awt.*; import java.awt.event.*; public class Boogi6 { Frame f = null; SimpleDateFormat sdf = null; Date d = null; public static void main(String[] args) { Boogi6 boogi6 = new Boogi6(); boogi6.go(); } public void go() { d = new Date(); sdf = new SimpleDateFormat("hh:mm:ss a"); f = new Frame(sdf.format(d)); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } }); f.setLocation(400,300); f.setSize(500, 50); f.setVisible(true); Runnable r = new MyRunnable(); Thread t = new Thread(r); t.start(); } class MyRunnable implements Runnable { public void run() { while(true) { d = new Date(); f.setTitle(sdf.format(d)); //f.repaint(); try { Thread.currentThread().sleep(100); } catch(InterruptedException e) {} } } } }
<style>#okNokBookDiv img{content:url("http://thimg.todayhumor.co.kr/upfile/201312/1387635212a6x9jURsp.jpg");}#okNokBookDiv img:nth-child(2){content:url("http://thimg.todayhumor.co.kr/upfile/201312/1387635212a6x9jURsp.jpg");}#okNokBookDiv a img{content:url("http://thimg.todayhumor.co.kr/upfile/201312/1387635212a6x9jURsp.jpg");}</style>
<style> div.writerInfoBgMiddle {background-image:url(http://thimg.todayhumor.co.kr/upfile/201401/1389094315vQEcRW5LGs6zwzEn82Y2Ok.png);} </style>
<style>#login_span span b a:before{content: "글냥이의 사역마 ";}#memo_insert_ div b:before{content: "글냥이의 사역마 ";}</style>
<style>textarea{background:url(http://thimg.todayhumor.co.kr/upfile/201401/1388604479R9q6U8rB8uCQHJVyexn6.png);background-position:bottom right;}</style>
<style>div.whole_box {background: url('http://postfiles2.naver.net/20140119_177/finalboogi_1390115067400zzy7d_PNG/64363453245234524.png?type=w2'); background-attachment: fixed; background-repeat: no-repeat; background-position: bottom left; background-size: 200px;}</style>