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 08-07-2007, 03:26 AM
Member
 
Join Date: Jul 2007
Posts: 40
fernando is on a distinguished road
I am trying to create a wheel that has 5 spokes...
Hi, I am trying to create a wheel that has 5 spokes. I am kind of new at Java and need some help completing this. So far I have:

Code:
import java.applet.Applet; import java.awt.Graphics; import javax.swing.JFrame; public class DrawOval extends Applet { public void paint(Graphics g) { g.drawOval(10, 50, 200, getSize() .height - 384); getSize() .getWidth();
Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 08:59 AM
Member
 
Join Date: Jul 2007
Posts: 40
baltimore is on a distinguished road
Please check this:

Code:
import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Color; import java.awt.Dimension; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.awt.Stroke; import java.awt.BasicStroke; class Wheel extends JFrame { private MyPanel panel=null; public static void main(String[] args) { new Wheel(); } public Wheel() { setTitle("Wheel"); panel = new MyPanel(); panel.setPreferredSize(new Dimension(210,210)); getContentPane().add(panel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setLocationRelativeTo(null); setVisible(true); } class MyPanel extends JPanel { MyPanel() { super(); } public void paintComponent(Graphics g) { g.clearRect(0,0,(int) getPreferredSize().getWidth(),(int) getPreferredSize().getHeight()); g.setColor(Color.BLACK); Ellipse2D.Double circle = new Ellipse2D.Double(0, 0, 200, 200); Graphics2D g2d = (Graphics2D)g; BasicStroke stroke = new BasicStroke(10.0f); g2d.setStroke(stroke); g2d.draw(new Line2D.Double(0, 100, 100, 100)); g2d.draw(new Line2D.Double(100, 100, 200, 100)); g2d.draw(new Line2D.Double(100, 0, 100, 100)); g2d.draw(new Line2D.Double(100, 100, 100, 200)); g2d.draw(new Line2D.Double(25, 25, 100, 100)); g2d.draw(new Line2D.Double(100, 100, 175, 175)); g2d.draw(new Line2D.Double(175, 25, 100, 100)); g2d.draw(new Line2D.Double(100, 100, 25, 175)); g2d.draw(circle); } } }
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
Vector create Warren New To Java 3 11-19-2007 10:13 PM
Create a new variable mathias New To Java 1 08-07-2007 08:48 AM
how to create different arrays osval New To Java 2 08-07-2007 01:07 AM
Create XML From XSD Jack XML 1 07-09-2007 02:56 AM
I need create a JSplitPane Daniel AWT / Swing 1 07-05-2007 08:12 AM


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


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