NOTE!NOTE!

chengwenying 2007-08-15 09:28:50
我编译以下代码的时候,报错咯,报错情况如下:
Note: Headlines.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
--------------------------------------------------
各位前辈能帮我解释下哪里错了吗?谢谢!分不多!
--------------------------------------------------
下面为代码
--------------------------------------------------







import java.awt.*;
import javax.swing.*;
import java.util.*;

public class Headlines extends JFrame{
HeadlinePanel news=new HeadlinePanel();
public Headlines(){
super("Headlines");
setSize(420,100);

JPanel pane=new JPanel();
pane.setLayout(new GridLayout(1,1,15,15) );
pane.add(news);
setContentPane(pane);
pane.show();
news.scroll();
}
public static void main(String[] args){
Headlines head =new Headlines();
}
}
class HeadlinePanel extends JPanel{
String[] headlines={
"000000000000000000000",
"111111111111111111111111",
"22222222222222222222222222",
"33333333333333333333333333333"
};
int y=76;
void scroll(){

while(true){
y=y-1;
if(y<75)
y=76;
repaint();
try{
Thread.sleep(250);
}catch(InterruptedException e){}
}
}
public void paintComponent(Graphics comp){
Graphics2D comp2D=(Graphics2D)comp;
Font type=new Font("serif",Font.BOLD,14);
comp2D.setFont(type);
comp2D.setColor(getBackground());
comp2D.fillRect(0,0,getSize().width,getSize().height);
comp2D.setColor(Color.black);
for(int i=0;i<headlines.length;i++)
comp2D.drawString(headlines[i],5,y+(20*i));
}
}
...全文
155 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
chengwenying 2007-08-16
  • 打赏
  • 举报
回复
应该是paintComponent
改成paintComponents吧
我这样试了不行,继续等待解决方案
zdjray 2007-08-15
  • 打赏
  • 举报
回复
应该是paintComponent
改成paintComponents吧
ansili521 2007-08-15
  • 打赏
  • 举报
回复
关注中...

62,614

社区成员

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

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