Results 1 to 3 of 3
  1. #1
    Keno777 is offline Member
    Join Date
    Oct 2009
    Rep Power

    Default Color Brown and Polygon help

    I am not sure how to make the color Brown in Java, and could also use a little help setting up a polygon as well. I need to put a polygon on top of a house as a roof but am missing something. Not sure if its the explicit parameters I am missing or what. Any help would be great. Thanks!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    You can make almost any color you want by creating a new Color(int, int, int). Look at the Color API for details, and also look at color chooser dialog to help you choose the right combination.

    With regard to your polygon, the question is a bit vague and thus may be difficult for us to help you on.

  3. #3
    oxano is offline Member
    Join Date
    Sep 2009
    Rep Power


    Find the RGB values of a color: http//

    simple program that draws 1 polygon. I think it's pretty clear what it does.
    You can either use a JPanel or a Canvas to draw on. I did it with a JPanel. If you want to use Canvas change "paintComponent" into "paint" and it will work.
    For more specific code with your roof on a house, your code would be very helpfull.

    Java Code:
    import javax.swing.*;
    import java.awt.*;
    public class Polygon extends JPanel {
        public Polygon(){
        public void paintComponent(Graphics g)
            int[] x = {10,500,250,50,90};
            int[] y = {500,250,300,140,570};
        public void createGUI(){
            JFrame frame = new JFrame("how to draw a polygon");
        public static void main(String[] args) {
            Polygon poly = new Polygon();
    Last edited by oxano; 10-04-2009 at 10:53 AM.

Similar Threads

  1. Drag polygon
    By cassysumandak in forum New To Java
    Replies: 5
    Last Post: 03-10-2011, 06:30 PM
  2. colllision rectangle-polygon
    By marina in forum New To Java
    Replies: 4
    Last Post: 01-28-2009, 09:14 AM
  3. polygon-shaped JComponent
    By zenMarko in forum New To Java
    Replies: 2
    Last Post: 11-04-2008, 06:06 PM
  4. How to Fill a Polygon in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-22-2008, 11:10 PM
  5. How to Draw a Polygon in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-22-2008, 11:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts