当前位置: 技术问答>java相关
请教代码出错,偶是菜鸟,感谢赐教
来源: 互联网 发布时间:2015-08-23
本文导语: import Java.awt.*; import Java.util.*; import Java.awt.event.*; import Java.applet.Applet; public class Bbs extends Applet { int count = 1; Label L = new Label("Intput:"); Button B1 = new Button("Sumbit"); Button B2 = new Button("Reset"); TextArea TA = n...
import Java.awt.*;
import Java.util.*;
import Java.awt.event.*;
import Java.applet.Applet;
public class Bbs extends Applet
{
int count = 1;
Label L = new Label("Intput:");
Button B1 = new Button("Sumbit");
Button B2 = new Button("Reset");
TextArea TA = new TextArea(10,25);
TextField TF = new TextField("Please write here!!^_^",15);
public void init()
{
TF.selectAll();
TA.setEditable(false);
B1.addMouseListener(new B1_Listener());
B2.addMouseListener(new B2_Listener());
add(L);
add(TF);
add(B1);
add(B2);
add(TA);
}
class B1_listener extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
Calendar C = Calendar.getInstance();
String yea = Integer.toString(C.get(Calendar.YEAR));
String mon = Integer.toString(C.get(Calendar.MONTH) + 1);
String day = Integer.toString(C.get(Calendar.DAY_OF_MONTH));
if(TF.getText().equals("")) return;
else
{
TA.append(yea + "YEAR" + mon + "MONTH" + day + "DAY");
TA.append(C.get(Calendar.HOUR_OF_DAY) + ":" + C.get(Calendar.MINUTE) + "n");
TA.append("Information" + (count ++) + "==>" + TF.getText() + "nn");
TF.setText("");
}
}
}
class B2_listener extends MounseAdapter
{
public void mouseClicked(MouseEvent e)
{
TF.setText("");
}
}
}
出错信息:
--------------------Configuration: j2sdk1.4.0 --------------------
D:javaBbs.java:1: package Java.awt does not exist
import Java.awt.*;
^
D:javaBbs.java:2: package Java.util does not exist
import Java.util.*;
^
D:javaBbs.java:3: package Java.awt.event does not exist
import Java.awt.event.*;
^
D:javaBbs.java:4: package Java.applet does not exist
import Java.applet.Applet;
^
D:javaBbs.java:5: cannot resolve symbol
symbol : class Applet
location: class Bbs
public class Bbs extends Applet
^
D:javaBbs.java:8: cannot resolve symbol
symbol : class Label
location: class Bbs
Label L = new Label("Intput:");
^
D:javaBbs.java:9: cannot resolve symbol
symbol : class Button
location: class Bbs
Button B1 = new Button("Sumbit");
^
D:javaBbs.java:10: cannot resolve symbol
symbol : class Button
location: class Bbs
Button B2 = new Button("Reset");
^
D:javaBbs.java:11: cannot resolve symbol
symbol : class TextArea
location: class Bbs
TextArea TA = new TextArea(10,25);
^
D:javaBbs.java:12: cannot resolve symbol
symbol : class TextField
location: class Bbs
TextField TF = new TextField("Please write here!!^_^",15);
^
D:javaBbs.java:26: cannot resolve symbol
symbol : class MouseAdapter
location: class Bbs.B1_listener
class B1_listener extends MouseAdapter
^
D:javaBbs.java:28: cannot resolve symbol
symbol : class MouseEvent
location: class Bbs.B1_listener
public void mouseClicked(MouseEvent e)
^
D:javaBbs.java:45: cannot resolve symbol
symbol : class MounseAdapter
location: class Bbs.B2_listener
class B2_listener extends MounseAdapter
^
D:javaBbs.java:47: cannot resolve symbol
symbol : class MouseEvent
location: class Bbs.B2_listener
public void mouseClicked(MouseEvent e)
^
D:javaBbs.java:8: cannot resolve symbol
symbol : class Label
location: class Bbs
Label L = new Label("Intput:");
^
D:javaBbs.java:9: cannot resolve symbol
symbol : class Button
location: class Bbs
Button B1 = new Button("Sumbit");
^
D:javaBbs.java:10: cannot resolve symbol
symbol : class Button
location: class Bbs
Button B2 = new Button("Reset");
^
D:javaBbs.java:11: cannot resolve symbol
symbol : class TextArea
location: class Bbs
TextArea TA = new TextArea(10,25);
^
D:javaBbs.java:12: cannot resolve symbol
symbol : class TextField
location: class Bbs
TextField TF = new TextField("Please write here!!^_^",15);
^
D:javaBbs.java:17: cannot resolve symbol
symbol : class B1_Listener
location: class Bbs
B1.addMouseListener(new B1_Listener());
^
D:javaBbs.java:18: cannot resolve symbol
symbol : class B2_Listener
location: class Bbs
B2.addMouseListener(new B2_Listener());
^
D:javaBbs.java:30: cannot resolve symbol
symbol : class Calendar
location: class Bbs.B1_listener
Calendar C = Calendar.getInstance();
^
D:javaBbs.java:30: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
Calendar C = Calendar.getInstance();
^
D:javaBbs.java:31: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
String yea = Integer.toString(C.get(Calendar.YEAR));
^
D:javaBbs.java:32: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
String mon = Integer.toString(C.get(Calendar.MONTH) + 1);
^
D:javaBbs.java:33: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
String day = Integer.toString(C.get(Calendar.DAY_OF_MONTH));
^
D:javaBbs.java:38: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
TA.append(C.get(Calendar.HOUR_OF_DAY) + ":" + C.get(Calendar.MINUTE) + "n");
^
D:javaBbs.java:38: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
TA.append(C.get(Calendar.HOUR_OF_DAY) + ":" + C.get(Calendar.MINUTE) + "n");
^
28 errors
Process completed.
import Java.util.*;
import Java.awt.event.*;
import Java.applet.Applet;
public class Bbs extends Applet
{
int count = 1;
Label L = new Label("Intput:");
Button B1 = new Button("Sumbit");
Button B2 = new Button("Reset");
TextArea TA = new TextArea(10,25);
TextField TF = new TextField("Please write here!!^_^",15);
public void init()
{
TF.selectAll();
TA.setEditable(false);
B1.addMouseListener(new B1_Listener());
B2.addMouseListener(new B2_Listener());
add(L);
add(TF);
add(B1);
add(B2);
add(TA);
}
class B1_listener extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
Calendar C = Calendar.getInstance();
String yea = Integer.toString(C.get(Calendar.YEAR));
String mon = Integer.toString(C.get(Calendar.MONTH) + 1);
String day = Integer.toString(C.get(Calendar.DAY_OF_MONTH));
if(TF.getText().equals("")) return;
else
{
TA.append(yea + "YEAR" + mon + "MONTH" + day + "DAY");
TA.append(C.get(Calendar.HOUR_OF_DAY) + ":" + C.get(Calendar.MINUTE) + "n");
TA.append("Information" + (count ++) + "==>" + TF.getText() + "nn");
TF.setText("");
}
}
}
class B2_listener extends MounseAdapter
{
public void mouseClicked(MouseEvent e)
{
TF.setText("");
}
}
}
出错信息:
--------------------Configuration: j2sdk1.4.0 --------------------
D:javaBbs.java:1: package Java.awt does not exist
import Java.awt.*;
^
D:javaBbs.java:2: package Java.util does not exist
import Java.util.*;
^
D:javaBbs.java:3: package Java.awt.event does not exist
import Java.awt.event.*;
^
D:javaBbs.java:4: package Java.applet does not exist
import Java.applet.Applet;
^
D:javaBbs.java:5: cannot resolve symbol
symbol : class Applet
location: class Bbs
public class Bbs extends Applet
^
D:javaBbs.java:8: cannot resolve symbol
symbol : class Label
location: class Bbs
Label L = new Label("Intput:");
^
D:javaBbs.java:9: cannot resolve symbol
symbol : class Button
location: class Bbs
Button B1 = new Button("Sumbit");
^
D:javaBbs.java:10: cannot resolve symbol
symbol : class Button
location: class Bbs
Button B2 = new Button("Reset");
^
D:javaBbs.java:11: cannot resolve symbol
symbol : class TextArea
location: class Bbs
TextArea TA = new TextArea(10,25);
^
D:javaBbs.java:12: cannot resolve symbol
symbol : class TextField
location: class Bbs
TextField TF = new TextField("Please write here!!^_^",15);
^
D:javaBbs.java:26: cannot resolve symbol
symbol : class MouseAdapter
location: class Bbs.B1_listener
class B1_listener extends MouseAdapter
^
D:javaBbs.java:28: cannot resolve symbol
symbol : class MouseEvent
location: class Bbs.B1_listener
public void mouseClicked(MouseEvent e)
^
D:javaBbs.java:45: cannot resolve symbol
symbol : class MounseAdapter
location: class Bbs.B2_listener
class B2_listener extends MounseAdapter
^
D:javaBbs.java:47: cannot resolve symbol
symbol : class MouseEvent
location: class Bbs.B2_listener
public void mouseClicked(MouseEvent e)
^
D:javaBbs.java:8: cannot resolve symbol
symbol : class Label
location: class Bbs
Label L = new Label("Intput:");
^
D:javaBbs.java:9: cannot resolve symbol
symbol : class Button
location: class Bbs
Button B1 = new Button("Sumbit");
^
D:javaBbs.java:10: cannot resolve symbol
symbol : class Button
location: class Bbs
Button B2 = new Button("Reset");
^
D:javaBbs.java:11: cannot resolve symbol
symbol : class TextArea
location: class Bbs
TextArea TA = new TextArea(10,25);
^
D:javaBbs.java:12: cannot resolve symbol
symbol : class TextField
location: class Bbs
TextField TF = new TextField("Please write here!!^_^",15);
^
D:javaBbs.java:17: cannot resolve symbol
symbol : class B1_Listener
location: class Bbs
B1.addMouseListener(new B1_Listener());
^
D:javaBbs.java:18: cannot resolve symbol
symbol : class B2_Listener
location: class Bbs
B2.addMouseListener(new B2_Listener());
^
D:javaBbs.java:30: cannot resolve symbol
symbol : class Calendar
location: class Bbs.B1_listener
Calendar C = Calendar.getInstance();
^
D:javaBbs.java:30: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
Calendar C = Calendar.getInstance();
^
D:javaBbs.java:31: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
String yea = Integer.toString(C.get(Calendar.YEAR));
^
D:javaBbs.java:32: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
String mon = Integer.toString(C.get(Calendar.MONTH) + 1);
^
D:javaBbs.java:33: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
String day = Integer.toString(C.get(Calendar.DAY_OF_MONTH));
^
D:javaBbs.java:38: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
TA.append(C.get(Calendar.HOUR_OF_DAY) + ":" + C.get(Calendar.MINUTE) + "n");
^
D:javaBbs.java:38: cannot resolve symbol
symbol : variable Calendar
location: class Bbs.B1_listener
TA.append(C.get(Calendar.HOUR_OF_DAY) + ":" + C.get(Calendar.MINUTE) + "n");
^
28 errors
Process completed.
|
java是区分大小写的。应该是:
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.applet.Applet;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.applet.Applet;
|
D:javaBbs.java:1: package Java.awt does not exist
import Java.awt.*;
^
D:javaBbs.java:2: package Java.util does not exist
import Java.util.*;
^
D:javaBbs.java:3: package Java.awt.event does not exist
import Java.awt.event.*;
^
D:javaBbs.java:4: package Java.applet does not exist
import Java.applet.Applet;
^
修正为:
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.applet.Applet;
Java -> java
import Java.awt.*;
^
D:javaBbs.java:2: package Java.util does not exist
import Java.util.*;
^
D:javaBbs.java:3: package Java.awt.event does not exist
import Java.awt.event.*;
^
D:javaBbs.java:4: package Java.applet does not exist
import Java.applet.Applet;
^
修正为:
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.applet.Applet;
Java -> java