Welcome to Dream.In.Code
Become a Java Expert!

Join 149,516 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,354 people online right now. Registration is fast and FREE... Join Now!




Polygons and adding labels to them

 
Reply to this topicStart new topic

Polygons and adding labels to them

snugglesmocha
4 Jul, 2007 - 07:08 AM
Post #1

New D.I.C Head
*

Joined: 14 Apr, 2007
Posts: 28


My Contributions


new.member


Group: Members
Joined: 14 Apr, 2007
Posts: 19


My Contributions



Two questions-

1. -I now know how to move my polygons horizontallly but how do I move them veritically???

2. Also I need to label my graphics--not sure how to do that. I attempted one of the graphics but got no result. I need to label ---square, rounded square, polygon, circle, oval, filled rectaangle and filled circle.

Here is my code

import java.applet.*;
import java.awt.*;
public class Project3Applet extends Applet
{

public void paint(Graphics gr)
{
Label grapicName = new Label("square");
Font bigFont = new Font("Helvetica", Font.BOLD,12);
gr.setFont(bigFont);
gr.setColor(Color.blue);
setBackground(Color.white);
gr.drawRoundRect(20,20,80,80,0,0);


gr.drawRoundRect(20,20,80,80,0,0);
gr.setColor(Color.magenta);
setBackground(Color.white);

gr.drawRoundRect(220,20,80,80,40,40);
gr.setColor(Color.cyan);
setBackground(Color.white);

gr.drawRoundRect(20,180,80,80,80,80);
gr.setColor(Color.green);
setBackground(Color.white);
gr.drawOval(190,190,120,60);

gr.setColor(Color.red);
setBackground(Color.white);
gr.drawRoundRect(20,320,75,75,80,80);

gr.setColor(Color.orange);
setBackground(Color.white);
gr.fillRect(200,330,120,60);

int xPoints[] = {162,172,192,172,180,160,135,148,129,152,162};
int yPoints[] = {158,180,188,200,235,205,222,195,178,180,158};
gr.setColor(Color.black);
gr.drawPolygon(xPoints, yPoints, xPoints.length);
}
}


Thanks for the help











User is offlineProfile CardPM
+Quote Post

Ryan747
RE: Polygons And Adding Labels To Them
9 Jul, 2007 - 11:36 PM
Post #2

New D.I.C Head
*

Joined: 16 Oct, 2006
Posts: 26


My Contributions
QUOTE(snugglesmocha @ 4 Jul, 2007 - 08:08 AM) *

Two questions-

1. -I now know how to move my polygons horizontallly but how do I move them veritically???

2. Also I need to label my graphics--not sure how to do that. I attempted one of the graphics but got no result. I need to label ---square, rounded square, polygon, circle, oval, filled rectaangle and filled circle.



like an animation moving vertically?

you are creating a label use BorderFactory in labeling your label...

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:07PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month