자바로 스탑워치 소스를 받았는데 각 소스마다 주석좀 달아주세요ㅠㅠ
Isolation
자바로짜퓆bsp;짜여진 스탑워치 프로그램 소스입니다.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class stopwatch extends jframe implements actionlistener, runnable
{
container con;
jbutton start,stop,reset;
boolean is;
jpanel top,center;
long hour=0;
long min=0;
long sec=0;
long msec=0;
string time=00 : 00 : 00 . 00;
canvas can;
public stopwatch()
{
init();
setdefaultcloseoperation(exit_on_close);
setsize(300,120);
setvisible(true);
}
public void init()
{
con=getcontentpane();
start=new jbutton(시작);
stop=new jbutton(중지);
reset=new jbutton(재설정);
top=new jpanel();
start.addactionlistener(this);
stop.addactionlistener(this);
reset.addactionlistener(this);
top.add(start);
top.add(stop);
top.add(reset);
con.add(top,north);
}
public void actionperformed(actionevent e)
{
jbutton jb=(jbutton)e.getsource();
if (jb==start)
{
is=true;
}
else if (jb==stop)
{
is=false;
}
else if (jb==reset)
{
resettimes();
}
}
public long minustimes()
{
long total=(hour*60*60*100)+(min*60*100)+(sec*100)+msec+1;
if (total=0)
{
is=false;
}
return total;
}
public void resettimes()
{
hour=0;
min=0;
sec=0;
msec=0;
time=00 : 00 : 00 . 00;
is=false;
repaint();
}
public void settimes()
{
long total=minustimes();
hour=(long)((total/100)/(60*60));
min=(long)((total/100)%(60*60)/60);
sec=(long)((total/100)%(60*60)%60);
msec=(long)(total-((hour*60*60*100)+(min*60*100)+(sec*100)));
string []times=new string[4];
times[0]=hour+;
times[1]=min+;
times[2]=sec+;
times[3]=msec+;
for (int i=0; i times.length ; ++i )
{
if (times[i].length()2)
{
times[i]=0+times[i];
}
}
time=times[0]+ : +times[1]+ : +times[2]+ . +times[3];
}
public void paint(graphics g)
{
g=getgraphics();
g.setcolor(color.white);
g.fillrect(0,70,400,100);
g.setcolor(color.black);
g.drawstring(time,100,100);
top.updateui();
}
public void run()
{
while (true)
{
if (is)
{
try
{
settimes();
repaint();
thread.sleep(10);
}
catch (exception e)
{
}
}
}
}
public static void main(string[] args)
{
new thread(new stopwatch()).start();
}
}
각 소스마다 설명좀 부탁드립니다ㅠㅠㅠ좀 급해요ㅠㅠㅠㅠㅠ
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2653851 | 자바 비동기 네트워크 질문입니다. | 벛꽃잎 | 2024-05-05 |
2653823 | 드림위버5로 div코딩 작업시 (10) | 미쿡 | 2024-05-05 |
2653797 | [HTML or JavaScript 질문요] 싸이2홈에 관한 (5) | 라임나무 | 2024-05-05 |
2653772 | [질문] JAVA로 제 컴에 있는 화상 카메라 제어 가능하겠죠? (2) | 환히찬 | 2024-05-04 |
2653721 | [플러그인]질문드립니다!! (3) | 이리온 | 2024-05-04 |
2653697 | 포문의 고수님들 도와주세여...포문이 복잡하네여.... | 족장 | 2024-05-04 |
2653671 | 메뉴 스크립트 문의드립니다. | 하루키 | 2024-05-03 |
2653637 | 자바 안드로이드를 시작하려고 합니다.이클립스 버전에 질문이. (3) | 영글 | 2024-05-03 |
2653578 | 소스 있는데 프로그램좀 만들어주실뿐.. (8) | 갤투 | 2024-05-03 |
2653550 | 첫화면에 인스타그램 피드 나오게 하고싶은데 | 눈 | 2024-05-02 |
2653528 | 이 두개 코드 차이점이 뭔가요? | 마중물 | 2024-05-02 |
2653444 | c# email을 db로 저장 시키기 (1) | 피네 | 2024-05-01 |
2653361 | 초보에유~ filter:gray; 이거 파폭에선 어케먹이나용 ㅠㅠㅋ | 마음새 | 2024-05-01 |
2653335 | 파일확장자 구하는 방법 질문을 합니다. (2) | 한가람 | 2024-04-30 |
2653305 | [질문] 무비클립과 텍스트 그냥 일반적으로 크기 축소시 문제.. | 한누리 | 2024-04-30 |
2653224 | 프린트하기 질문입니다. | 파라 | 2024-04-29 |
2653194 | 이미지에 텍스트 삽입 질문드려요 | 라임나무 | 2024-04-29 |
2653164 | 페이지 로딩시 특정 div 투명값 조절 (1) | 은별 | 2024-04-29 |
2653136 | C언어를 배우고있는 왕초보 프로그래머 지망생입니다 (2) | 베레기 | 2024-04-29 |
2653111 | 이렇게 레이아웃 짜는거 맞나요? (3) | 은G | 2024-04-28 |