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: Need help in creating new simple java GUI with rectangle, square, moving object, etc.

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Need help in creating new simple java GUI with rectangle, square, moving object, etc.

    Hello, I'm new to this forum and completely new to java programming. I'm thinking of creating java GUI with the use of swing. But I'm completely lost. What I'm trying to do is to create a football field GUI. It goes like this:

    First, I want to create filled green color rectangle which will be used as the playing field which 800 pixels long by 400 pixels wide. A white rectangle outline will be used as boundary. The goal will be 200 pixels long. The ball will be 50 pixels wide. Then, a rectangle with red color will be used to represent players on the field and oval (with black color) will be used to represent ball. Next, I want to create a long rectangle with blue color which will be use as game timer and put it above the field.

    Here how it look like:
    Snap7.jpg

    I have view some tutorials about Animate Circles, Bouncing Balls, Moving and Scaling, Re size Rectangle, Show Clock Timer, etc. But I'm clueless. So I really hope that this forum will not disappoint me.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,349
    Thanks
    49
    Thanked 2,203 Times in 2,176 Posts

    Default Re: Need help in creating new simple java GUI with rectangle, square, moving object,

    Start by write a class that extends JFrame and adding a JPanel to it in which you will do the drawing.
    Override the JPanel's paintComponent method and add code to it to do the drawing.
    Do a simple drawing at first and add to it as you go along.

  3. The Following User Says Thank You to Norm For This Useful Post:

    Maxly (November 10th, 2011)

  4. #3
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Need help in creating new simple java GUI with rectangle, square, moving object,

    Alternatively to Norm's good advice, if you don't mind veering away from Java (only a little bit), you could try using Processing to create what you need, as with any other language of-course.
    It's basically Java, but with drawing made way simpler and quicker to produce. You basically focus on drawing instead of the layouts and frames.

    And of-course, if this is an Assignment or what-not, this might not be good advice, but something to look into if It's a personal project, maybe .


    If you're interested, KevinWorkman also produced a good read of Processing which you might want to take a look at.
    http://www.javaprogrammingforums.com...rocessing.html
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  5. The Following User Says Thank You to newbie For This Useful Post:

    Maxly (November 10th, 2011)

  6. #4
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Need help in creating new simple java GUI with rectangle, square, moving object,

    Thanks for the advice guys.. Right now I'm using Eclipse Helios with WindowBuilder. I've done the drawing but still struggling on the next step..

Similar Threads

  1. Creating and implementing class for creating a calendar object
    By kumalh in forum Object Oriented Programming
    Replies: 3
    Last Post: July 29th, 2011, 08:40 AM
  2. Using a string when creating an object.
    By ZeroLRS in forum Object Oriented Programming
    Replies: 10
    Last Post: July 13th, 2011, 09:22 PM
  3. Creating an object...
    By RodePope4546 in forum Object Oriented Programming
    Replies: 6
    Last Post: June 27th, 2011, 06:44 AM
  4. Creating Servlet object
    By tcstcs in forum Java Servlet
    Replies: 3
    Last Post: May 9th, 2011, 02:13 AM
  5. Java object help(should be simple)
    By Mirak in forum Object Oriented Programming
    Replies: 5
    Last Post: May 8th, 2010, 09:43 PM