제가 만든 소스 한번 봐주시고 수정 할 꺼 있으면 말해주세요. (실행은 되지만 깜빡거리네요)
이플
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 flag;
JPanel jp;
long hour=0;
long min=0;
long sec=0;
long msec=0;
String time=00 : 00 : 00 . 00;public Stopwatch()
{
init();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(330,140);
setBackground(Color.white);
setTitle(지원자 금영훈 입니다.);
setVisible(true);
}
public void init()
{
con=getContentPane();
start=new JButton(Start);
stop=new JButton(Stop);
reset=new JButton(Reset);
jp=new JPanel();
jp.setBackground(Color.white);
start.addActionListener(this);
stop.addActionListener(this);
reset.addActionListener(this);
jp.add(start);
jp.add(stop);
jp.add(reset);
con.add(jp,South);
}
public void actionPerformed(ActionEvent e)
{
JButton jb=(JButton)e.getSource();
if (jb==start)
{
flag=true;
}
else if (jb==stop)
{
flag=false;
}
else if (jb==reset)
{
resetTimes();
}
}
public long plusTimes()
{
long total=(hour*60*60*100)+(min*60*100)+(sec*100)+msec+1;
return total;
}
public void resetTimes()
{
time=00 : 00 : 00 . 00;
flag=false;
repaint();
}
public void setTimes()
{
long total=plusTimes();
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(40,30,250,60);
Font font = new Font(, Font.BOLD, 30);
g.setFont(font);
g.setColor(Color.black);
g.drawString(time,63,73);
jp.updateUI();
}
public void run()
{
while (true)
{
if (flag)
{
try
{
setTimes();
repaint();
Thread.sleep(9);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}
public static void main(String[] args)
{
new Thread(new Stopwatch()).start();
}
}-------------------------------------------------------------------------------------------------------------------
왜 깜빡거리는 걸까요? ㅠㅠ