高手帮看下.不胜感激
编译报错
F:\javalesson>javac changecolor.java
changecolor.java:31: incompatible types
found : java.awt.Scrollbar
required: java.awt.Scrollbar[]
scrBar=new Scrollbar(Scrollbar.VERTICAL);
^
changecolor.java:32: cannot resolve symbol
symbol : method add (java.awt.Scrollbar[])
location: class changecolor
add(scrBar);
^
changecolor.java:33: cannot resolve symbol
symbol : method reshape (int,int,int,int)
location: class java.awt.Scrollbar[]
scrBar.reshape(100+80*i,5,20,160);
^
changecolor.java:34: cannot resolve symbol
symbol : method setValues (int,int,int,int)
location: class java.awt.Scrollbar[]
scrBar.setValues(50,0,0,10);
^
changecolor.java:35: cannot resolve symbol
symbol : method getValue ()
location: class java.awt.Scrollbar[]
labelColor=new Label(Text+scrBar.getValue(),Label.LEFT);
^
changecolor.java:35: incompatible types
found : java.awt.Label
required: java.awt.Label[]
labelColor=new Label(Text+scrBar.getValue(),Label.LEFT);
^
changecolor.java:36: cannot resolve symbol
symbol : method add (java.awt.Label[])
location: class changecolor
add(labelColor);
^
changecolor.java:37: cannot resolve symbol
symbol : method setBackground (java.awt.Color)
location: class java.awt.Label[]
labelColor.setBackground(Color.green);
^
changecolor.java:38: cannot resolve symbol
symbol : method reshape (int,int,int,int)
location: class java.awt.Label[]
labelColor.reshape(100+80*i,165,40,20);
^
changecolor.java:64: cannot resolve symbol
symbol : method getValue ()
location: class java.awt.Scrollbar[]
labelColor.setText(Text+scrBar.getValue());
^
changecolor.java:64: cannot resolve symbol
symbol : method setText (java.lang.String)
location: class java.awt.Label[]
labelColor.setText(Text+scrBar.getValue());
^
changecolor.java:73: cannot resolve symbol
symbol : method getValue ()
location: class java.awt.Scrollbar[]
value=(float)(scrBar.getValue()/100f);
^
changecolor.java:73: incompatible types
found : float
required: float[]
value=(float)(scrBar.getValue()/100f);
^
Note: changecolor.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
13 errors
问一下什么原因,怎么改
源码
import java.awt.*;
import java.applet.*;
import vrml.external.Browser;
import vrml.external.Node;
import vrml.external.field.EventInSFColor;
public class changecolor extends Applet{
Scrollbar scrBar[]=new Scrollbar[3];
Label labelColor[]=new Label[3];
Label labelDemo;
Browser browser;
Node myMaterial;
String Text[]={"R=","G=","B="};
boolean isScenceLoading=true;
public void start(){
while (isScenceLoading){
try{
browser=Browser.getBrowser(this);
myMaterial=(Node)(browser.getNode("ConeColor"));
isScenceLoading=false;
labelDemo.setText("TestColor");
}
catch(Exception e){labelDemo.setText("VRML Loading");}
}
}
public void init(){
super.init();
setLayout(null);
resize(240,240);
setBackground(Color.orange);
for(int i=0;i<3;i++){
scrBar=new Scrollbar(Scrollbar.VERTICAL);
add(scrBar);
scrBar.reshape(100+80*i,5,20,160);
scrBar.setValues(50,0,0,10);
labelColor=new Label(Text+scrBar.getValue(),Label.LEFT);
add(labelColor);
labelColor.setBackground(Color.green);
labelColor.reshape(100+80*i,165,40,20);
}
labelDemo=new Label("TestColor",Label.CENTER);
add(labelDemo);
labelDemo.reshape(320,70,80,80);
labelDemo.setBackground(new Color(122,122,122));
}
public boolean handleEvent(Event event){
for(int i=0;i<3;i++){
if (event.id==Event.SCROLL_LINE_UP&&event.target==scrBar){
setColorLabel(event,i);
return true;
}
else if(event.id==Event.SCROLL_LINE_DOWN&&event.target==scrBar){
setColorLabel(event,i);
return true;
}
else if(event.id==Event.SCROLL_ABSOLUTE&&event.target==scrBar){
setColorLabel(event,i);
return true;
}
}
return super.handleEvent(event);
}
public void setColorLabel(Event ev,int i){
Color demoColor;
labelColor.setText(Text+scrBar.getValue());
demoColor=new Color((int)(2.55*scrBar[0].getValue()),
(int)(2.55*scrBar[1].getValue()),
(int)(2.55*scrBar[2].getValue())
);
labelDemo.setBackground(demoColor);
float value[]=new float[3];
EventInSFColor newColor=(EventInSFColor)myMaterial.getEventIn("set_diffuseColor");
for(i=0;i<3;i++)
value=(float)(scrBar.getValue()/100f);
newColor.setValue(value);
}
}