목차
Clock.class
Clock.java
DigitalClockViewer.class
DigitalClockViewer.java
SegmentComponent.class
SegmentComponent.java
15.3KB
Clock.java
DigitalClockViewer.class
DigitalClockViewer.java
SegmentComponent.class
SegmentComponent.java
15.3KB
본문내용
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.JComponent;
/**
* A component that draws current time like digital clock.
*/
public class SegmentComponent extends JComponent implements Runnable {
Thread th;
Clock now = new Clock();
/**
* Constructs a SegmentComponent with a given number user entered.
*
* @param number
* the number user entered of 0 to 9
*/
public SegmentComponent() {
th = new Thread(this);
th.start();
}
// Construct seven segment and draw to match the number
// When the number user entered is 0.
public void zero(Graphics2D g2, int x) {
a(g2, x);
b(g2, x);
c(g2, x);
d(g2, x);
e(g2, x);
f(g2, x);
}
// When the number user entered is 1.
public void one(Graphics2D g2, int x) {
b(g2, x);
c(g2, x);
}
// When the number user entered is 2.
public void two(Graphics2D g2, int x) {
a(g2, x);
b(g2, x);
g(g2, x);
e(g2, x);
d(g2, x);
}
// When the number user entered is 3.
public void three(Graphics2D g2, int x) {
a(g2, x);
b(g2, x);
g(g2, x);
c(g2, x);
d(g2, x);
}
import javax.swing.JPanel;
import javax.swing.JComponent;
/**
* A component that draws current time like digital clock.
*/
public class SegmentComponent extends JComponent implements Runnable {
Thread th;
Clock now = new Clock();
/**
* Constructs a SegmentComponent with a given number user entered.
*
* @param number
* the number user entered of 0 to 9
*/
public SegmentComponent() {
th = new Thread(this);
th.start();
}
// Construct seven segment and draw to match the number
// When the number user entered is 0.
public void zero(Graphics2D g2, int x) {
a(g2, x);
b(g2, x);
c(g2, x);
d(g2, x);
e(g2, x);
f(g2, x);
}
// When the number user entered is 1.
public void one(Graphics2D g2, int x) {
b(g2, x);
c(g2, x);
}
// When the number user entered is 2.
public void two(Graphics2D g2, int x) {
a(g2, x);
b(g2, x);
g(g2, x);
e(g2, x);
d(g2, x);
}
// When the number user entered is 3.
public void three(Graphics2D g2, int x) {
a(g2, x);
b(g2, x);
g(g2, x);
c(g2, x);
d(g2, x);
}
키워드
추천자료
무선 모바일 자바 프로그래밍을 통한 logbook의 구현
소스보기 방법
[프로그램]자바를 이용한 그래픽 툴 만들기
국내 게임업계의 원소스 멀티유즈 Trend와 Needs
원소스멀티유즈론
[컴퓨터 공학]자바 한단계 높이기(워드자료)
JAVA메모장소스
채팅 프로그램(자바)
테트리스 - 자바
Java 게임소스코드 (게임. 체스게임. Kight 체스게임. 2인용게임. Java awt 기반 객체지향 게임)
[자바 프로그램] ‘X번째 소수 구하기!’
안드로이드 MediaPlayer 예제 소스파일 (소스.zip) 입니다.
컴퓨터네트워크 - 자바 소켓프로그래밍을 이용한 야구게임
소개글