为什么我在JAVA中覆盖paintcomponent方法时说不能覆盖或实现超类方法
@SuppressWarnings("serial")classSingleWaveformPanelextendsPanel{publicAudioInfoa=null...
@SuppressWarnings("serial")
class SingleWaveformPanel extends Panel
{
public AudioInfo a = null;
SingleWaveformPanel(AudioInfo a)
{
this.a = a;
}
@Override
protected void paintComponent(Graphics g)
{
int oldx = 0;
int oldy = (int) (getHeight()/2);
int xIndex = 0;
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(),getHeight());
int t = 0;
int increment = a.buf.length/getWidth();
g.setColor(Color.RED);
for(t = 0; t<a.buf.length;t+=1)
{
double scaleFactor = a.toReturn[0][t]/getHeight();
double scalesample = a.buf[t] * scaleFactor;
int y = (int)((getHeight()/2)-(scalesample));
g.drawLine(oldx,oldy,xIndex,y);
xIndex++;
oldx = xIndex;
oldy = y;
}
}
} 展开
class SingleWaveformPanel extends Panel
{
public AudioInfo a = null;
SingleWaveformPanel(AudioInfo a)
{
this.a = a;
}
@Override
protected void paintComponent(Graphics g)
{
int oldx = 0;
int oldy = (int) (getHeight()/2);
int xIndex = 0;
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(),getHeight());
int t = 0;
int increment = a.buf.length/getWidth();
g.setColor(Color.RED);
for(t = 0; t<a.buf.length;t+=1)
{
double scaleFactor = a.toReturn[0][t]/getHeight();
double scalesample = a.buf[t] * scaleFactor;
int y = (int)((getHeight()/2)-(scalesample));
g.drawLine(oldx,oldy,xIndex,y);
xIndex++;
oldx = xIndex;
oldy = y;
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询