Results 1 to 3 of 3
Thread: Color Brown and Polygon help
- 10-02-2009, 08:09 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
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!
-
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.
- 10-04-2009, 10:51 AM #3
Member
- Join Date
- Sep 2009
- Posts
- 5
- Rep Power
- 0
Find the RGB values of a color: http//bguide.blogspot.com/2008/02/howto-find-rgb-values-of-color.html
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(){ createGUI(); } public void paintComponent(Graphics g) { int[] x = {10,500,250,50,90}; int[] y = {500,250,300,140,570}; g.drawPolygon(x,y,5); } public void createGUI(){ JFrame frame = new JFrame("how to draw a polygon"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(this); frame.pack(); frame.setSize(800,600); frame.setVisible(true); } public static void main(String[] args) { Polygon poly = new Polygon(); } }Last edited by oxano; 10-04-2009 at 10:53 AM.
Similar Threads
-
Drag polygon
By cassysumandak in forum New To JavaReplies: 5Last Post: 03-10-2011, 06:30 PM -
colllision rectangle-polygon
By marina in forum New To JavaReplies: 4Last Post: 01-28-2009, 09:14 AM -
polygon-shaped JComponent
By zenMarko in forum New To JavaReplies: 2Last Post: 11-04-2008, 06:06 PM -
How to Fill a Polygon in Java
By Java Tip in forum java.awtReplies: 0Last Post: 06-22-2008, 11:10 PM -
How to Draw a Polygon in Java
By Java Tip in forum java.awtReplies: 0Last Post: 06-22-2008, 11:09 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks