Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

background

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, if i want to draw a line which is the same color as the backgound, how do i set the color for the graphics object?
g.color(???);
g.drawLine(x1,y1,x2,y2);
thanks.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yourComponent.getBackground();
 
Syamsul Hussin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, but if im using an applet, how to get the applet's background color? i cannot find getBackgound() method in the applet documentation.thanks
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is because getBackground() isn't a direct member of Applet. It is a actually a member of Component which is an ancestor class to Applet. This means that you can still call it with an Applet object. However, to find it in the API you must look at the Component class. Note that the API for Applet has a list of all fields and methods that are inherited from its ancestor classes.
HTH
Layne
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic