Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-09-2008, 03:11 PM
Zebra's Avatar
Member
 
Join Date: Apr 2008
Posts: 41
Zebra is on a distinguished road
[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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-09-2008, 03:15 PM
Zosden's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 221
Zosden is on a distinguished road
I think there is one in the java 2d package
__________________
Definition of Impossible = making a good game in Java.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-09-2008, 03:18 PM
Zebra's Avatar
Member
 
Join Date: Apr 2008
Posts: 41
Zebra is on a distinguished road
Quote:
Originally Posted by Zosden View Post
I think there is one in the java 2d package
Sorry, but what is that/ and where can I find it.

Is there just a code on how to make one?

like here is how to make a rectangle in a Java Applet:
Code:
setBackground(Color.black); page.fillRect(0, 175, 300, 50);
__________________
I am a Java n00b.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-09-2008, 04:09 PM
Member
 
Join Date: May 2008
Posts: 5
damounh is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-12-2008, 02:45 PM
Zebra's Avatar
Member
 
Join Date: Apr 2008
Posts: 41
Zebra is on a distinguished road
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.
Code:
setBackground(Color.black); page.fillRect(0, 175, 300, 50);
__________________
I am a Java n00b.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-12-2008, 03:39 PM
Member
 
Join Date: May 2008
Posts: 5
damounh is on a distinguished road
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

Code:
int[] xPoints = {100,50,150}; int[] yPoints = {100,200,200}; g.drawPolygon(xPoints, yPoints, 3);
theres also fillPolygon in case you wish to color it in. You can find all the drawing methods here

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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-20-2008, 03:23 PM
Zebra's Avatar
Member
 
Join Date: Apr 2008
Posts: 41
Zebra is on a distinguished road
Thanks everybody. I just drew lines to make a triangle roof. Here is the code:

Code:
//Roof page.setColor (Color.white); page.drawLine (MID+1, TOP+1, MID-70, TOP+50); page.setColor (Color.white); page.drawLine (MID+1, TOP+1, MID+70, TOP+50);
__________________
I am a Java n00b.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pascal Triangle help Magic101 New To Java 4 05-01-2008 08:51 PM
Computing the area of a triangle using Heron's Formula Java Tip java.lang 0 04-12-2008 09:39 PM
change the square to triangle java anotsu New To Java 2 02-06-2008 08:21 PM
Making triangle banie New To Java 4 02-02-2008 12:23 PM
Triangle jkswebsite New To Java 6 01-14-2008 04:33 AM


All times are GMT +3. The time now is 02:48 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org