Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-02-2009, 11:10 PM
Member
 
Join Date: Mar 2009
Posts: 4
Rep Power: 0
mlfatty is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 03-03-2009, 04:27 PM
Steve11235's Avatar
Senior Member
 
Join Date: Dec 2008
Posts: 972
Rep Power: 2
Steve11235 is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-04-2009, 07:36 AM
Member
 
Join Date: Mar 2009
Posts: 4
Rep Power: 0
mlfatty is on a distinguished road
Default
Thanks. I am moving forward with this program.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
how to get input from User Alvaro New To Java 7 01-16-2010 12:02 AM
loop when there is no user-input becky New To Java 12 02-02-2009 11:02 PM
who to take user input ,not by console... Shyam Singh New To Java 3 06-13-2008 11:09 PM
Prompting user input of a string. apfroggy0408 New To Java 3 03-09-2008 07:23 PM
cant take input from user new_1 New To Java 6 12-25-2007 08:38 AM


All times are GMT +2. The time now is 03:14 AM.



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