我编译以下代码的时候,报错咯,报错情况如下:
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));
}
}
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));
}
}
解决方案 »
- 我要做一个学生管理系统,请问下具体步骤和操作
- 求助,命令提示符中执行java命令行出现could not find main class
- 生成的BMP图片内容为空?
- 好心人帮我看下这一小段代码是怎么回事,想不通啊.
- 一道笔试题...关于按位取补的
- java多线程的问题,wait以后,怎么无法notifyAll
- 窗口问题
- 菜鸟问题,关于String数组
- 请问如何编写windows下运行的application程序?怎样生成exe文件???
- 选择城市中总是添加不到定义的那些城市 ,哪里错了?求指点
- 请问这个是什么错误?
- java新人报道第一问:servlet中有没有象asp中的response.end那样的功能?另外
改成paintComponents吧
改成paintComponents吧
我这样试了不行,继续等待解决方案