Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
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 04-18-2008, 04:04 AM
Member
 
Join Date: Apr 2008
Posts: 15
fluffy is on a distinguished road
Need help
I am new to Java...I am trying to draw several images in one drawing panel, but i can,t able to do..here are the details
The overall drawing panel is size 500 x 350. Its background color
is cyan. The rectangular area behind each grid of circles is green, and the background of the circles is yellow.
The rectangles and circles are outlined in black. Each grid also has a pair of lines drawn across it in an "X"
pattern. The six figures on your drawing panel should have the following properties.
Description (x, y) position size of subfigure circles per subfigure rows/cols
top-left (0, 0) 100 x 100 10 N / A
top-middle (160, 0) 60 x 60 6 N / A
top-right (250, 30) 100 x 100 5 N / A
bottom-left (10, 170) 48 x 48 4 3 x 3
bottom-middle (180, 190) 24 x 24 3 5 x 5
bottom-right (340, 170) 72 x 72 9 2 x 2

The 100x100 subfigure has 10 circles, and each circle has a gap of 5 pixels from any others (a total of 20 gaps for both directions...the thing is I have to use only parameters and for loops..could any one help me for this .
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-18-2008, 06:22 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
And what is your question?

What have you done so far?

regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 06:53 AM
Member
 
Join Date: Apr 2008
Posts: 15
fluffy is on a distinguished road
need help
import java.awt.*;

public class Circles {
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(500, 350);
panel.setBackground(Color.CYAN);
Graphics g = panel.getGraphics();

g.setColor(Color.YELLOW);
for(int i=0; i<10; i++) {
g.fillCircle(i*5, i*5, 100-i*5, 100-i*5);

g.setColor(Color.BLACK);

g.drawOval(0, 0, 100-i*5, 100-i*5);
}
}
}
i just tried to draw the first fig but not able to.....
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-18-2008, 07:05 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Hi fluffy,

First of all, welcome to the Java Forums.

I have one question to ask from you. Are use any Java IDE for your coding? Or just work on a text editor like Notepad?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-18-2008, 07:20 AM
Member
 
Join Date: Apr 2008
Posts: 15
fluffy is on a distinguished road
i have written the code on jGrasp
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-18-2008, 07:07 PM
Member
 
Join Date: Apr 2008
Posts: 15
fluffy is on a distinguished road
Hey
could any one can help me to solve this problem....please
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 04-18-2008, 07:17 PM
Member
 
Join Date: Apr 2008
Posts: 28
fireball2008 is on a distinguished road
Send a message via AIM to fireball2008
Quote:
Originally Posted by sukatoa View Post
And what is your question?

What have you done so far?

regards,
sukatoa
ask those question too many times, without answer the question the askers ask.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 04-18-2008, 07:22 PM
Member
 
Join Date: Apr 2008
Posts: 28
fireball2008 is on a distinguished road
Send a message via AIM to fireball2008
Quote:
Originally Posted by fluffy View Post
import java.awt.*;

public class Circles {
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(500, 350);
panel.setBackground(Color.CYAN);
Graphics g = panel.getGraphics();

g.setColor(Color.YELLOW);
for(int i=0; i<10; i++) {
g.fillCircle(i*5, i*5, 100-i*5, 100-i*5);

g.setColor(Color.BLACK);

g.drawOval(0, 0, 100-i*5, 100-i*5);
}
}
}
i just tried to draw the first fig but not able to.....

I think the class have to extends JFrame and setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

and then add(panel);

let me know if I answer your questions.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 04-18-2008, 07:25 PM
Member
 
Join Date: Apr 2008
Posts: 28
fireball2008 is on a distinguished road
Send a message via AIM to fireball2008
Here is one of the example I done:
import javax.swing.JFrame;
import java.awt.*;

public class BallApp extends JFrame {
private BallPanel _ballP, _ball2;
public BallApp(String title)
{super(title);
setSize(510,510);
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
_ballP = new BallPanel();
add(_ballP);

setVisible(true);}
public static void main(String[] args){
BallApp app = new BallApp("Color Chaning Ball");
}
}


note that ballPanel is a panel class you have to add panel in to the Frame
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 04-18-2008, 09:54 PM
Member
 
Join Date: Apr 2008
Posts: 15
fluffy is on a distinguished road
i need to write the code in import java.awt.*
by using for loops and parameters...
i don't understand this import javax.swing.JFrame;
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 04-19-2008, 04:19 AM
Member
 
Join Date: Apr 2008
Posts: 28
fireball2008 is on a distinguished road
Send a message via AIM to fireball2008
Quote:
Originally Posted by fluffy View Post
i need to write the code in import java.awt.*
by using for loops and parameters...
i don't understand this import javax.swing.JFrame;
I know you have to write in awt, but in order to display it you have to display it in JFrame , JFrame is like a board that you can put the panel on. import is just importing the classes in java. for example import java.awt.* is like import the class in awt that you will use like the panels and many other. so import javax.swing.JFrame is like importing the JFrame class so you can use it.
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 04-19-2008, 04:21 AM
Member
 
Join Date: Apr 2008
Posts: 28
fireball2008 is on a distinguished road
Send a message via AIM to fireball2008
Here is modifield version check if works:
import java.awt.*;
import javax.swing.JFrame;


public class Circles extends JFrame{
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(500, 350);
add(panel);
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
panel.setBackground(Color.CYAN);
Graphics g = panel.getGraphics();

g.setColor(Color.YELLOW);
for(int i=0; i<10; i++) {
g.fillCircle(i*5, i*5, 100-i*5, 100-i*5);

g.setColor(Color.BLACK);

g.drawOval(0, 0, 100-i*5, 100-i*5);
}
}
}
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 04-19-2008, 05:25 AM
Member
 
Join Date: Apr 2008
Posts: 15
fluffy is on a distinguished road
Thanks fireball2008 for the response....
i tried to compile that code but it is showing the errors
Circles.java:11: cannot find symbol
symbol : method fillCircle(int,int,int,int)
location: class java.awt.Graphics
g.fillCircle(i*5, i*5, 100-i*5, 100-i*5);
^
1 error

i wrote fillOval instead of circle then it compiled but the thing is the output was not the same i am trying to get....i need to fill the circles with yellow color and the outline of the circle should be black..but the thing is here i am getting the circles filled with both yellow and black..i need only outline of the circle should be black
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 04-20-2008, 03:57 AM
Member
 
Join Date: Apr 2008
Posts: 28
fireball2008 is on a distinguished road
Send a message via AIM to fireball2008
well, I didn't know about drawing the outline black, but I am confused with
"the circles filled with both yellow and black" what do u mean by that, it should only fill with one color, try delete the line
"g.setColor(Color.BLACK);" and see what happens.
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



All times are GMT +3. The time now is 12:42 PM.


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