请问cannot resolve symbol的一个问题

Kenight_ 2007-09-06 04:44:48
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import ch08.Time3;

public class TimeTest5 extends JApplet implements ActionListener{

private Time3 time;
private JLabel hourLabel, minuteLabel, secondLabel;
private JTextArea hourField, minuteField, secondField, displayField;
private JButton tickButton;

public void init()
{
time = new Time3();

Container container = getContenPane();
container.setLayout( new FlowLayout() );

hourLabel = new JLabel( "Set Hour" );
hourField = new JTextArea( 10 );
hourField.addActionListener( this );
container.add( hourLabel );
container.add( hourField );

minuteLabel = new JLabel( "Set minute" );
minuteField = new JTextArea( 10 );
minuteField.addActionListener( this );
container.add( minuteLabel );
container.add( minuteField );

secondLabel = new JLabel( "Set second" );
secondField = new JTextArea( 10 );
secondField.addActionListener( this );
container.add( secondLabel );
container.add( secondField );

displayField = new JTextArea( 30 );
displayField.setEditable( false );
container.add( displayField );

tickButton = new JButton( "Add 1 to second" );
tickButton.addActionListener( this );
container.add( tickButton );

updateDisplay();
}

public void actionPerformed( ActionEvent actionEvent )
{
if ( actionEvent.getSource() == tickButton )
tick();
else if ( actionEvent.getSource() == hourField )
{
time.setHour( Integer.parseInt( actionEvent.getActionCommand() ) );
hourField.setText( "" );
}
else if ( actionEvent.getSource() == minuteField )
{
time.setMinute( Integer.parseInt( actionEvent.getActionCommand() ) );
minuteField.setText( "" );
}
else if ( actionEvent.getSource() == secondField )
{
time.setSecond( Integer.parseInt( actionEvent.getActionCommand() ) );
secondField.setText( "" );
}
updateDisplay();
}

public void updateDisplay()
{
displayField.setText( "Hour:" + time.getHour() +
"; Minute: " + time.getMinute() +
"; Second: " + time.getSecond() );

showStatus( "Standard time is: " + time.toString() +
"; Universal time is: " + time.toUniversalString() );
}

public void tick()
{
time.setSecond( (time.getSecond() + 1 ) % 60 );

if ( time.getSecond() == 0 )
{
time.setMinute( ( time.getMinute() + 1 ) % 60 );

if ( time.getMinute() == 0 )
time.setHour( ( time.getHour() + 1 ) % 24 );
}
}
}

******************************************
编译时提示错误:
cannot resolve symbol method getContenPane ()
cannot resolve symbol constructor JTextArea (int)
cannot resolve symbol method addActionListener (TimeTest5)
cannot resolve symbol constructor JTextArea (int)
cannot resolve symbol method addActionListener (TimeTest5)
cannot resolve symbol constructor JTextArea (int)
cannot resolve symbol method addActionListener (TimeTest5)
cannot resolve symbol constructor JTextArea (int)
**********************************************
ch08.Time3 是自定义的包 
sdk安装在D盘 编写的程序和自定义的包在E盘
设置过环境变量
其它没有 import 自定义包 的程序都能正确编译和执行
不知是怎么回事?
...全文
704 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kenight_ 2007-09-07
  • 打赏
  • 举报
回复
原来是我几个地方写错了 THX
liky5387 2007-09-06
  • 打赏
  • 举报
回复
以下是JAVA DOC中的所有JTextArea构造函数。它没有一个是接收一个int参数的.
new JTextArea(10),它会去调JTextArea(String text) 构造函数,它会把new JTextArea(10)中的10当成一个String 变量,而这个变量你又没有声明,它找不到,所以就会报cannot resolve symbol异常.
-------------------------------------
JTextArea()
构造一个新的 TextArea。
JTextArea(Document doc)
构造一个新的 JTextArea,使其具有给定的文档模型,所有其他参数均默认为 (null, 0, 0)。
JTextArea(Document doc, String text, int rows, int columns)
构造具有指定行数和列数以及给定模型的新的 JTextArea。
JTextArea(int rows, int columns)
构造具有指定行数和列数的新的空 TextArea。
JTextArea(String text)
构造显示指定文本的新的 TextArea。
JTextArea(String text, int rows, int columns)
构造具有指定文本、行数和列数的新的 TextArea。
dreamfly_888 2007-09-06
  • 打赏
  • 举报
回复
JApplet 没有这个方法 getContenPane()

new JTextArea( 10 ) //JTextArea没有只带一个参数的构造函数

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧