File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes Colouring a rectangle Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Colouring a rectangle" Watch "Colouring a rectangle" New topic
Author

Colouring a rectangle

bachir samir
Greenhorn

Joined: Mar 13, 2010
Posts: 1
Hi

This is my first post, I want to draw a rectangle with a blue colour, but the problem is that the method is not recognized (this thing drives me mad) can you please help me to set the colour.



Thank you in advance.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 12865

Look in the API documentation for the java.lang.Color class and you will find a list of the valid constant values. And remember that Java is case-sensitive, in other words "blue" and "Blue" and "BLUE" are three different things.

This message was edited 1 time. Last update was at by Paul Clapham

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 25057
Moving to our GUIs forum.
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 17253

Paul Clapham wrote:Look in the API documentation for the java.lang.Color class and you will find a list of the valid constant values. And remember that Java is case-sensitive, in other words "blue" and "Blue" and "BLUE" are three different things.

Color.blue and Color.BLUE are both supported. The problem is that Rectangle has no method called setBackground.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 25057
Wouldn't you override the paintComponent() method and call the fillRectangle() or similar method of the Graphics object?
Remember to write super.paintcomponent(g); as the first statement in the paintComponent method.
 
 
subject: Colouring a rectangle
 
MyEclipse, The Clear Choice