Results 1 to 5 of 5
  1. #1
    cka
    cka is offline Member
    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0

    Default draw shape with user defined values

    Hi,
    I want to learn to do GUIs
    what I'm trying to do currently is to draw a shape e.g. square,circle by taking values from a user.
    i.e. user enters coordinates x,y, width,height in text field and then the shape is drawn.
    I cannot find any examples of something like this.

    I currently take values from the text field using action listener but i have problems with passing it to a shape and then drawing it.

    Can you point me to same examples? or tell me step by step how to do it?

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Let's work with your code first of all since you'll understand it best and we'll see what problems you are having. If you do post code in this forum, please don't forget to use code tags so that your code remains readable. To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

    Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:

    Java Code:
    [code]
      // your code goes here
      // notice how the top and bottom tags are different
    [/code]
    Much luck!

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default

    Normally you draw in the paintComponent() method for the GUI component that is to show the drawing.
    The GUI collects the input from the user (rect coordinates) and waits for the user to press a button. The action listener for the button then edits the data and calls repaint() to request the JVM to call the paint method. When the paint method is called, it takes the data edited by the listener and draws.

  5. #5
    cka
    cka is offline Member
    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0

Similar Threads

  1. Replies: 0
    Last Post: 05-20-2010, 09:18 PM
  2. User Defined Method
    By overcranked in forum New To Java
    Replies: 6
    Last Post: 04-09-2010, 02:02 AM
  3. JSP with user-defined java classes
    By adammyth in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 03-05-2010, 07:13 PM
  4. RegardingSgould Enter in user defined inbox
    By Prashant.surwade in forum CLDC and MIDP
    Replies: 0
    Last Post: 09-23-2009, 02:21 PM
  5. Replies: 0
    Last Post: 07-16-2007, 09:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •