当前位置: 代码迷 >> J2SE >> NOTE!NOTE
  详细解决方案

NOTE!NOTE

热度:318   发布时间:2016-04-24 14:07:55.0
NOTE!NOTE!
我编译以下代码的时候,报错咯,报错情况如下:
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));
}
}

------解决方案--------------------
关注中...
------解决方案--------------------
应该是paintComponent
改成paintComponents吧
  相关解决方案