• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

setBackground error

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried compiling this program
import java.awt.*;
import java.applet.*;

public class Excercise extends Applet {
public void init() {

Frame f = new Frame("First Frame");
f.setSize(200,200);
String E = "Excercise- test area should not have scrollbars and should not be editable ";

TextArea ta = new TextArea(E,8,TextArea.SCROLLBARS_NONE);
ta.setEditable(false);
// ta.setBackground(Color.black);// line 1
// ta.setForeground(Color.yellow); // line 2
f.add(ta);
f.pack();
f.setVisible(true);


}
}
I am getting the folloing compiler error. ie error at line 1 and 2
Excercise java:14:No variable black defined in class Color
Excercise java:15:No variable yellow defined in class Color
can anyone pls tell me whats happening?
Am i missing something??
-bani
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very strange..
I copied and pasted your source code, removed the comments, and it still compiled in my machine.
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also embedded the applet in an HTML page and it's working. Are you sure you are compiling the right file?
I also edited your code so that you can now close the frame:

[ August 02, 2002: Message edited by: Anthony Villanueva ]
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic