java编译时提示错误:找不到符号
代码如下:publicclassclock{publicstaticvoidmain(Stringargs[]){ClockViewcv=newClockView();c...
代码如下:
public class clock
{
public static void main(String args[])
{
ClockView cv = new ClockView();
cv.SetVisible(true);
try
{
for(;;)
{
cv.refreshTimeDisplay();
Thread.sleep(500);
}
}catch (Exception e)
{System.out.println("Error:"+e);}
}
}
class ClockView extends javax.swing.JFrame
{
private javax.swing.JLabel tLabel = new javax.swing.JLabel();
ClockView()
{this.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
this.setSize(95,45);
this.getContentPane().add(tLabel);
this.refreshTimeDisplay();
}
protected String getDigitsAsString(int i)
{
String str = Integer.toString(i);
if(i<10) str="0"+str;
return str;
}
public void refreshTimeDisply(){
Timestamp t= new Timestamp();
t.fillTimes();
String display = getDigitsAsSting(t.hrs) + ":" + getDigitsAsSting(t.mins) + ":" + getDigitsAsString(t.secs);
tLabel.setText(" "+ display);
tLabel.repaint();
}
}
class Timestamp
{
int hrs,mins,secs ;
void fillTimes(){
java.util.Calender now ;
now = java.util.Calendar.getInstance() ;
hrs = now.get(java.util.Calendar.HOUR_OF_DAY);
mins = now.get(java.util.Calendar.MINUTE);
secs = now.get(java.util.Calendar.SECOND);
}
} 展开
public class clock
{
public static void main(String args[])
{
ClockView cv = new ClockView();
cv.SetVisible(true);
try
{
for(;;)
{
cv.refreshTimeDisplay();
Thread.sleep(500);
}
}catch (Exception e)
{System.out.println("Error:"+e);}
}
}
class ClockView extends javax.swing.JFrame
{
private javax.swing.JLabel tLabel = new javax.swing.JLabel();
ClockView()
{this.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
this.setSize(95,45);
this.getContentPane().add(tLabel);
this.refreshTimeDisplay();
}
protected String getDigitsAsString(int i)
{
String str = Integer.toString(i);
if(i<10) str="0"+str;
return str;
}
public void refreshTimeDisply(){
Timestamp t= new Timestamp();
t.fillTimes();
String display = getDigitsAsSting(t.hrs) + ":" + getDigitsAsSting(t.mins) + ":" + getDigitsAsString(t.secs);
tLabel.setText(" "+ display);
tLabel.repaint();
}
}
class Timestamp
{
int hrs,mins,secs ;
void fillTimes(){
java.util.Calender now ;
now = java.util.Calendar.getInstance() ;
hrs = now.get(java.util.Calendar.HOUR_OF_DAY);
mins = now.get(java.util.Calendar.MINUTE);
secs = now.get(java.util.Calendar.SECOND);
}
} 展开
展开全部
public class clock
{
public static void main(String args[])
{
ClockView cv = new ClockView();
cv.setVisible(true);//这里setVisible错了
try {
for (;;) {
cv.refreshTimeDisply();//这里refreshTimeDisply错了
Thread.sleep(500);
}
} catch (Exception e)
{
System.out.println("Error:" + e);
}
}
}
class ClockView extends javax.swing.JFrame
{
private javax.swing.JLabel tLabel = new javax.swing.JLabel();
ClockView()
{
this
.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
this.setSize(95, 45);
this.getContentPane().add(tLabel);
this.refreshTimeDisply(); //这个单词错了
}
protected String getDigitsAsString(int i)
{
String str = Integer.toString(i);
if (i < 10)
str = "0" + str;
return str;
}
public void refreshTimeDisply() {
Timestamp t = new Timestamp();
t.fillTimes();
String display = getDigitsAsString(t.hrs) + ":"
+ getDigitsAsString(t.mins) + ":"
+ getDigitsAsString(t.secs); // 这个getDigitsAsString写错了
tLabel.setText(" " + display);
tLabel.repaint();
}
}
class Timestamp
{
int hrs, mins, secs;
void fillTimes() {
java.util.Calendar now ; //这个Calendar 错了
now = java.util.Calendar.getInstance() ;
hrs = now.get(java.util.Calendar.HOUR_OF_DAY);
mins = now.get(java.util.Calendar.MINUTE);
secs = now.get(java.util.Calendar.SECOND);
}
}
主要就是几个方法的单词写错了
{
public static void main(String args[])
{
ClockView cv = new ClockView();
cv.setVisible(true);//这里setVisible错了
try {
for (;;) {
cv.refreshTimeDisply();//这里refreshTimeDisply错了
Thread.sleep(500);
}
} catch (Exception e)
{
System.out.println("Error:" + e);
}
}
}
class ClockView extends javax.swing.JFrame
{
private javax.swing.JLabel tLabel = new javax.swing.JLabel();
ClockView()
{
this
.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
this.setSize(95, 45);
this.getContentPane().add(tLabel);
this.refreshTimeDisply(); //这个单词错了
}
protected String getDigitsAsString(int i)
{
String str = Integer.toString(i);
if (i < 10)
str = "0" + str;
return str;
}
public void refreshTimeDisply() {
Timestamp t = new Timestamp();
t.fillTimes();
String display = getDigitsAsString(t.hrs) + ":"
+ getDigitsAsString(t.mins) + ":"
+ getDigitsAsString(t.secs); // 这个getDigitsAsString写错了
tLabel.setText(" " + display);
tLabel.repaint();
}
}
class Timestamp
{
int hrs, mins, secs;
void fillTimes() {
java.util.Calendar now ; //这个Calendar 错了
now = java.util.Calendar.getInstance() ;
hrs = now.get(java.util.Calendar.HOUR_OF_DAY);
mins = now.get(java.util.Calendar.MINUTE);
secs = now.get(java.util.Calendar.SECOND);
}
}
主要就是几个方法的单词写错了
追问
能否详细说一下单词怎么错了?那个this.refreshTimeDisply()我修改了是this.refreshTimeDisplay()。
至于getDigitsAsString是怎么错了,还有Calendar
追答
getDigitsAsString这个没错 String display =这个你前面两个写成getDigitsAsSting了 而Calendar这个是你写成Calender了 java.util 里面没这个 就是个别的字母错了 上面代码我都给你改完了 你照着我标的那几个地方改你的程序 你就知道了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class clock
{
public static void main(String args[])
{
ClockView cv = new ClockView();
cv.setVisible(true); //大小写
try
{
for (;;)
{
cv.refreshTimeDisply(); //单词拼错,下同
Thread.sleep(500);
}
} catch (Exception e)
{
System.out.println("Error:" + e);
}
}
}
class ClockView extends javax.swing.JFrame
{
private javax.swing.JLabel tLabel = new javax.swing.JLabel();
ClockView()
{
this.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
this.setSize(95, 45);
this.getContentPane().add(tLabel);
this.refreshTimeDisply();
}
protected String getDigitsAsString(int i)
{
String str = Integer.toString(i);
if (i < 10)
str = "0" + str;
return str;
}
public void refreshTimeDisply() {
Timestamp t = new Timestamp();
t.fillTimes();
String display = getDigitsAsString(t.hrs) + ":" //单词拼错
+ getDigitsAsString(t.mins) + ":" + getDigitsAsString(t.secs);
tLabel.setText(" " + display);
tLabel.repaint();
}
}
class Timestamp
{
int hrs, mins, secs;
void fillTimes() {
java.util.Calendar now; //Calendar拼错
now = java.util.Calendar.getInstance();
hrs = now.get(java.util.Calendar.HOUR_OF_DAY);
mins = now.get(java.util.Calendar.MINUTE);
secs = now.get(java.util.Calendar.SECOND);
}
}
{
public static void main(String args[])
{
ClockView cv = new ClockView();
cv.setVisible(true); //大小写
try
{
for (;;)
{
cv.refreshTimeDisply(); //单词拼错,下同
Thread.sleep(500);
}
} catch (Exception e)
{
System.out.println("Error:" + e);
}
}
}
class ClockView extends javax.swing.JFrame
{
private javax.swing.JLabel tLabel = new javax.swing.JLabel();
ClockView()
{
this.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
this.setSize(95, 45);
this.getContentPane().add(tLabel);
this.refreshTimeDisply();
}
protected String getDigitsAsString(int i)
{
String str = Integer.toString(i);
if (i < 10)
str = "0" + str;
return str;
}
public void refreshTimeDisply() {
Timestamp t = new Timestamp();
t.fillTimes();
String display = getDigitsAsString(t.hrs) + ":" //单词拼错
+ getDigitsAsString(t.mins) + ":" + getDigitsAsString(t.secs);
tLabel.setText(" " + display);
tLabel.repaint();
}
}
class Timestamp
{
int hrs, mins, secs;
void fillTimes() {
java.util.Calendar now; //Calendar拼错
now = java.util.Calendar.getInstance();
hrs = now.get(java.util.Calendar.HOUR_OF_DAY);
mins = now.get(java.util.Calendar.MINUTE);
secs = now.get(java.util.Calendar.SECOND);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询