Results 1 to 3 of 3
  1. #1
    mlfatty is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default Getting User Input to Drawing Shapes

    Hi I am developing a program that allows users to draw shapes like Rectangle, Oval, Triangle on a JFrame. The user will select a shape from a menu items and then I am supposed to ask the user to enter specifications of the shape he selected like: location, size and color of the shape. I have JMenu that deals with the shape selection but I dont know how to present a input form so that the user can enter specifications of the shape. I tried JOptionPane's ShowInputDialog but I cant handle that. Does anyone know the best/easier way of getting input form the user??? I also want to know how I will be able to identify the color the user entered in the input form because there are a whole bunch of colors the user can type in the form. I will end up changing the location and size to ints or doubles(most probably ints).
    Thanks.

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    First, never draw, etc. directly in a JFrame, even though it seems to allow it. The convenience methods actually write on the RootPane's ContentPane. Instead, always add a container to the ContentPane, such as a JPanel, and draw, etc., on that.

    Now that you are drawing on a JPanel, you can add a JDialog. Use that to get the user input.

  3. #3
    mlfatty is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

Similar Threads

  1. how to get input from User
    By Alvaro in forum New To Java
    Replies: 7
    Last Post: 01-16-2010, 12:02 AM
  2. loop when there is no user-input
    By becky in forum New To Java
    Replies: 12
    Last Post: 02-02-2009, 11:02 PM
  3. who to take user input ,not by console...
    By Shyam Singh in forum New To Java
    Replies: 3
    Last Post: 06-13-2008, 11:09 PM
  4. Prompting user input of a string.
    By apfroggy0408 in forum New To Java
    Replies: 3
    Last Post: 03-09-2008, 07:23 PM
  5. cant take input from user
    By new_1 in forum New To Java
    Replies: 6
    Last Post: 12-25-2007, 08:38 AM

Posting Permissions

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