Easy Applet Question

G

GRoll21

Hey guys I'm new to java and just self-teaching my self. If i wanna set
the background to a color of my choice, i need the rgb numbers. so i
got them but how can I put them in so its correct syntax?

here is what I have..

setBackground(Color(135,206,250));

i've tried many things and looked in jdk and just don't understand it.
If anyone can tell me that would be great. Its so easy i'll feel stupid
when you tell me. Thanks for your help.
 
R

Roedy Green

setBackground(Color(135,206,250));

you need setBackground(new Color(135,206,250));

or beter still:

private static final Color DARKTURQUOISE = new Color( 0x00ced1 );

setBackground( DARKTURQUOISE );

Or this way to make it easier to change the colour scheme:

// colours used
private static final Color DARKTURQUOISE = new Color( 0x00ced1 );
....
// colour scheme
public static final Color PANEL_BACKGROUND = DARKTURQUOISE;
....
setBackground( PANEL_BACKGROUND );
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top