Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program with 'java.awt.Choice' doesn't compile in JDK1.3

 
Saurav Chetia
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code -
import java.awt.*;
import java.awt.event.*;
class colorTest extends Frame {
java.awt.Choice ColorChooser = new java.awt.Choice();
ColorChooser.insert("Green",0);
ColorChooser.add("Red");
ColorChooser.add("Blue");

public colorTest() {
super("ColorTest");
}
public static void main(String args[]) {
colorTest test = new colorTest();
}
}
When I try to compile the file I get the error as given below. What could be the problem ? -
javac colorTest.java
colorTest.java:7: <identifier> expected
ColorChooser.add("Red");
^
colorTest.java:8: <identifier> expected
ColorChooser.add("Blue");
^
colorTest.java:7: cannot resolve symbol
symbol : class add
location: package ColorChooser
ColorChooser.add("Red");
^
colorTest.java:8: cannot resolve symbol
symbol : class add
location: package ColorChooser
ColorChooser.add("Blue");
^
4 errors
 
basha khan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hei friend ,
call the methods from constructor,cut and paste the Choice API calls to the colortest constructor. then compile ..that's all.
basha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic