티스토리 뷰
//Label을 상속받는 깜박임레이블 클래스를 정의한다.
class FlickeringLabel extends Label implements Runnable {
public FlickeringLabel(String str) {
super(str);
// 스레드 생성 및 시작
Thread thread = new Thread(this);
thread.start();
}
@Override
public void run() {
// TODO Auto-generated method stub
int n = 0;
while (true) {
if (n == 0)
setBackground(Color.YELLOW);
else
setBackground(Color.GREEN);
if (n == 0)
n = 1;
else
n = 0;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
return;
}
}
}
}
class FlickeringLabelEx extends Frame {
public FlickeringLabelEx() {
setTitle("Flickering Label Ex");
FlickeringLabel fl1 = new FlickeringLabel("껌뻑");
Label fl2 = new Label("안 껌뻑");
FlickeringLabel fl3 = new FlickeringLabel("또 껌뻑");
// 깜박이는 레이블과 정상적인 레이블 생성
Panel p = new Panel();// 패널 생서하고..
p.add(fl1); // 패널에 레이블 붙임
p.add(fl2);
p.add(fl3);
add(p); // 프레임에 패널을 붙임
setSize(300, 100);
setVisible(true);
}
}
public class FlickeringLabelMain {
public static void main(String[] args) {
// TODO Auto-generated method stub
new FlickeringLabelEx();
}
}
'java,web study > 3주차 (7월 15일 ~21일)' 카테고리의 다른 글
텍스트필드 컴포넌트 (0) | 2013.07.17 |
---|---|
리스트 컴포넌트 (0) | 2013.07.17 |
Label (0) | 2013.07.17 |
제네릭 (0) | 2013.07.16 |
빠른 열거 (0) | 2013.07.16 |
- Total
- Today
- Yesterday
- 도전과제
- 정렬
- ERP
- SVN
- db
- 소켓
- 안드로이드
- CSS
- 이론
- 파이썬
- 졸업작품
- 데이터베이스
- 오라클
- 청주
- 자바
- 프로젝트
- 자바스크립트
- 메모장
- 정보
- 아두이노
- 알고리즘
- 배열
- HTML
- 클래스
- 게임
- JQuery
- jsp
- 잡담
- 충북대
- SQL
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |