Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How I can create those shapes with Java?

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default How I can create those shapes with Java?

    Greeting all ,

    I want to know what i need to create two shapes as represented in the photo, Is there already an exsiting class/pakcage in Java ? if not I wish somebody guide me.


    I tried to insert the picture by the Image tool in this thread but it didn't work will so I am providing the link of the photo below.

    2shared - download digital shapes.png



    Thank you
    Last edited by Learner; November 17th, 2010 at 09:11 AM.


  2. #2
    Member
    Join Date
    Oct 2010
    Posts
    40
    Thanks
    0
    Thanked 2 Times in 1 Post

    Default Re: How I can create those shapes with Java?

    what do you want to do? paint those shapes on a component like JFrame or JPanel? or would you like to put that picture in a jpanel or frame?

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: How I can create those shapes with Java?

    i want to drag the shape and drop it on the work area the same idea as the following photo


    2shared - download Example.png

  4. #4
    Member
    Join Date
    Oct 2010
    Posts
    40
    Thanks
    0
    Thanked 2 Times in 1 Post

    Default Re: How I can create those shapes with Java?

    i see.. do u use NetBeans IDE?

    compile this class and drag it to your workarea, see what happens.

    import java.awt.Graphics;
    import java.awt.Polygon;
    import javax.swing.JComponent;
     
    public class MyShape extends JComponent{
     
        @Override
        public void paint(Graphics g) {
     
           Polygon p = new Polygon();
           p.addPoint(50, 0);
           p.addPoint(0, 50);
           p.addPoint(50, 100);
           p.addPoint(100, 50);
     
           g.drawPolygon(p);
     
        }
    }

    if you compiled it and dragged to ur workarea, it will create a diamond shape. use that as a sample to create the shape u wanted. hope that helped.

Similar Threads

  1. Create a file specifying the size JAVA
    By Harbox in forum Java Theory & Questions
    Replies: 3
    Last Post: September 20th, 2012, 10:30 AM
  2. Java error "could not create java virtual machine"
    By aubrey4444 in forum Java Theory & Questions
    Replies: 17
    Last Post: October 3rd, 2010, 12:51 PM
  3. demarkating portions of images in different shapes
    By forgetlosing in forum Java Theory & Questions
    Replies: 0
    Last Post: March 25th, 2010, 08:41 AM
  4. Converting Images to Shapes
    By Ian in forum Java Theory & Questions
    Replies: 2
    Last Post: February 7th, 2010, 04:18 PM
  5. Java Source/APIs to create a Fourm
    By softwarebuzz in forum Java Theory & Questions
    Replies: 2
    Last Post: January 9th, 2010, 12:46 AM