已解决问题
谷歌yunmenshanx用户在2014.06.16提交了关于“雪中悍行j**a 找不到符号”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-11-14T12:48:52。packagech11;importj**ax.swing.*;
importj**a.awt.*;
importj**a.util.*;
classRefreshTimeThreadextendsThread
{
privateCalendartargetTime;
publicRefreshTimeThread(CalendartargetTime)
{
this.targetTime=targetTime;
}
publicvoidrun()
{
while(true)
{
CalendartodayTime=newGregorianCalendar();
longseconds=(targetTime.getTimeInMillis()-
todayTime.getTimeInMillis())/1000;
if(seconds<=0)
{
label.setText("时间到了!");
bre**;
}
intday=(int)(seconds/(24*60*60));
inthour=(int)(seconds/(60*60)%24);
intmin=(int)(seconds/60%60);
intsec=(int)(seconds%60);
Stringstr=day+"天"+hour+"时"+min+"分"+sec+"秒";
label.setText(str);
try
{
Thread.sleep(1000);
}
catch(InterruptedExceptione)
{
e.printStackTrace();
}
}
}
}
publicclassTimeFrame
{
privateJFramejf;
privateJLabellabel1;
privateJLabellabel;
publicTimeFrame()
{
jf=newJFrame("Time");
label1=newJLabel("距考研还有:");
label=newJLabel("");
jf.add(label1,BorderLayout.NORTh**);
jf.add(label,***.CENTER);
Threadt=newRefreshTimeThread(newGregorianCalendar
(2011,Calendar.JA**ARY,1,0,0,0));
t.start();
}
publicvoidshowMe()
{
jf.setBounds(200,200,300,150);
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLO**);
}
publicstaticvoidmain(String[]args)
{
newTimeFrame().showMe();
}
}
系统提示ch11\***.j**a:22:找不到符号
符号:变量label
位置:类ch11.RefreshTimeThread
label.setText("时间到了!");
^
ch11\***.j**a:30:找不到符号
符号:变量label
位置:类ch11.RefreshTimeThread
label.setText(str);
^
2错误希望大家能够帮助她。
详细问题描述及疑问:packagech11;
importj**ax.swing.*;
importj**a.awt.*;
importj**a.util.*;
classRefreshTimeThreadextendsThread
{
privateCalendartargetTime;
publicRefreshTimeThread(CalendartargetTime)
{
this.targetTime=targetTime;
}
publicvoidrun()
{
while(true)
{
CalendartodayTime=newGregorianCalendar();
longseconds=(targetTime.getTimeInMillis()-
todayTime.getTimeInMillis())/1000;
if(seconds<=0)
{
label.setText("时间到了!");
bre**;
}
intday=(int)(seconds/(24*60*60));
inthour=(int)(seconds/(60*60)%24);
intmin=(int)(seconds/60%60);
intsec=(int)(seconds%60);
Stringstr=day+"天"+hour+"时"+min+"分"+sec+"秒";
label.setText(str);
try
{
Thread.sleep(1000);
}
catch(InterruptedExceptione)
{
e.printStackTrace();
}
}
}
}
publicclassTimeFrame
{
privateJFramejf;
privateJLabellabel1;
privateJLabellabel;
publicTimeFrame()
{
jf=newJFrame("Time");
label1=newJLabel("距考研还有:");
label=newJLabel("");
jf.add(label1,BorderLayout.NORTh**);
jf.add(label,***.CENTER);
Threadt=newRefreshTimeThread(newGregorianCalendar
(2011,Calendar.JA**ARY,1,0,0,0));
t.start();
}
publicvoidshowMe()
{
jf.setBounds(200,200,300,150);
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLO**);
}
publicstaticvoidmain(String[]args)
{
newTimeFrame().showMe();
}
}
系统提示ch11\***.j**a:22:找不到符号
符号:变量label
位置:类ch11.RefreshTimeThread
label.setText("时间到了!");
^
ch11\***.j**a:30:找不到符号
符号:变量label
位置:类ch11.RefreshTimeThread
label.setText(str);
^
2错误期待您的答案,希望你能感受到,我最真诚的谢意
!