Results 1 to 7 of 7
- 05-09-2008, 02:11 PM #1
[SOLVED] How do I make a triangle?
Hey I am really new to applets, we are making them in class and we are suppose to create a house in the night with blinking stars. I know how to do everything, but make a triangle for my roof. I know how to make a triangle in regular java, but not one for an applet.
So how do you you make an triangle in an applet?I am a Java n00b.
- 05-09-2008, 02:15 PM #2
I think there is one in the java 2d package
My IP address is 127.0.0.1
- 05-09-2008, 02:18 PM #3
- 05-09-2008, 03:09 PM #4
Member
- Join Date
- May 2008
- Posts
- 5
- Rep Power
- 0
why dont you create two classes, one will be the applet, the other will be JPanel, and in the applet create an instance of the JPanel class and add it to the applet. then in the JPanel use the paint functions to draw just like drawing normally in java.
Damoun.H.
- 05-12-2008, 01:45 PM #5
Sorry, I don't understand how to do that. But is there a code on how to make a triangle like there is to make a rectangle? If so can you give me it. Thanks, sorry I don't understand, but I am only in programming I.
Java Code:setBackground(Color.black); page.fillRect(0, 175, 300, 50);
I am a Java n00b.
- 05-12-2008, 02:39 PM #6
Member
- Join Date
- May 2008
- Posts
- 5
- Rep Power
- 0
there are no functions that would draw a triangle for you, however you can use the polygon method in graphics to make any shape you like
heres how it works
theres also fillPolygon in case you wish to color it in. You can find all the drawing methods hereJava Code:int[] xPoints = {100,50,150}; int[] yPoints = {100,200,200}; g.drawPolygon(xPoints, yPoints, 3);
i notice ur setting the background color to black, make sure you set the draw color to something else cuz by defaults its black.
Damoun.H.
- 05-20-2008, 02:23 PM #7
Similar Threads
-
change the square to triangle java
By anotsu in forum New To JavaReplies: 3Last Post: 07-09-2009, 11:17 AM -
Triangle
By jkswebsite in forum New To JavaReplies: 8Last Post: 01-10-2009, 02:08 PM -
Pascal Triangle help
By Magic101 in forum New To JavaReplies: 4Last Post: 05-01-2008, 07:51 PM -
Computing the area of a triangle using Heron's Formula
By Java Tip in forum java.langReplies: 0Last Post: 04-12-2008, 08:39 PM -
Making triangle
By banie in forum New To JavaReplies: 4Last Post: 02-02-2008, 11:23 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks