자바로 스탑워치 소스를 받았는데 각 소스마다 주석좀 달아주세요ㅠㅠ
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();
}
}
각 소스마다 설명좀 부탁드립니다ㅠㅠㅠ좀 급해요ㅠㅠㅠㅠㅠ
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2652843 | HTMl , PHP 스마트폰 질문! (1) | 다스리 | 2024-04-26 |
2652817 | td 속성 지정 setAttribute (7) | 키클 | 2024-04-26 |
2652796 | 자바로 그래프를 그릴수 있나요? | 아론아브라함 | 2024-04-25 |
2652741 | 같은 IE10 인데도 다르네요.. (10) | 채련 | 2024-04-25 |
2652688 | ppk 자스 거의 다 봤는데요~ 또 추천 바랍니다. | 에일린 | 2024-04-24 |
2652660 | 예약이 연동되는 우커머스 플러그인이 있을까요? | 이뻐 | 2024-04-24 |
2652633 | css검사한 결과 (1) | 똥덩어리 | 2024-04-24 |
2652548 | 플래시에서 이미지(JPEG,JPG) 제어하는 방법을 알고싶습니다. (4) | 유1혹 | 2024-04-23 |
2652523 | 그래프할때 위로 되는데 밑으로 해서 올라올려면 (4) | 파라나 | 2024-04-23 |
2652492 | 자바 영화예매 하는 프로그램만들어야하는데요 | 크나 | 2024-04-23 |
2652409 | 고수분들 답해주세요~~~~~ (3) | 애교 | 2024-04-22 |
2652386 | 자바초보 - 입력스트림 에러 질문이요.. (1) | SweetChoco | 2024-04-22 |
2652333 | 이미지게시판에서 리스트페이지 이미지갯수조절하는법? (1) | 찬슬기 | 2024-04-21 |
2652307 | 이미지 아이콘에 대해서 ..(JButton) | ChocoHoilc | 2024-04-21 |
2652275 | VS 2003 에서 #이 자동으로 맨 앞으로 가는 문제 | 눈솔 | 2024-04-21 |
2652245 | .net 으로 만든 dll 파일 java에서 호출해서 쓰기? | 휘율 | 2024-04-20 |
2652220 | 페이지 스크롤 문제입니다.. !!! (2) | 벛꽃 | 2024-04-20 |
2652190 | 페이스북 코멘트 관련 문의 드립니다. | 행운아 | 2024-04-20 |
2652162 | JSP 코딩중에 에러발생하여 질문올립니다. (3) | 마루 | 2024-04-20 |
2652129 | 급한 질문이 있어요 ㅜㅡ (1) | 잉간 | 2024-04-19 |