Results 1 to 7 of 7
  1. #1
    juhess88 is offline Member
    Join Date
    Nov 2012
    Posts
    13
    Rep Power
    0

    Default how does the user choose an integer size - (using JFrame Jpanel...)

    Hey guys. I made an application that let's the user choose:

    1. shape - line, rectangle, circle

    how does the user choose an integer size - (using JFrame Jpanel...)-shape.jpg

    2. border color - using jcolorchooser

    how does the user choose an integer size - (using JFrame Jpanel...)-border-color.jpg

    3. filling color - using jcolorchooser

    how does the user choose an integer size - (using JFrame Jpanel...)-filling-color.jpg

    final result:

    how does the user choose an integer size - (using JFrame Jpanel...)-rectangle.jpg

    How do I let the user choose for example the size of the rectangle?

    Is there some sort of popup like JColorChooser that let's a user choose the integer size?

    **I use Eclipse.

    ***Here's my code:

    http://www.filedropper.com/model

    *Run the program in class Application. That's where you can see my work

    Thanks in advance
    Last edited by juhess88; 12-18-2012 at 12:56 PM.

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: how does the user choose an integer size - (using JFrame Jpanel...)

    Take a look here, maybe you can come up with a dialog?
    How to Make Dialogs (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    Especially the chapter "Getting the User's Input from a Dialog" should be of interest for you.
    I like likes!

  3. #3
    juhess88 is offline Member
    Join Date
    Nov 2012
    Posts
    13
    Rep Power
    0

    Default Re: how does the user choose an integer size - (using JFrame Jpanel...)

    Thanks.

    I'm going through the article but I don't know how to use it to create the size of my rectangle

    i would think to do something like showInputDialogue - and choose 5 for example. And since it's a String convert it to an int somehow.

    But how could I use it with my rectangle?

  4. #4
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: how does the user choose an integer size - (using JFrame Jpanel...)

    Well, you have defined your rectangle somewhere in your code, right?
    The Java rectangle object has properties you may change using myRectangle.setSize(width, height)...
    You may read in the string and parse it to an integer by using Integer.parseInt(...). This integer you may use in the method mentioned.

    One thing: Please paste your code inside the forum code brackets and not as external file. We will not download files usually.
    I like likes!

  5. #5
    juhess88 is offline Member
    Join Date
    Nov 2012
    Posts
    13
    Rep Power
    0

    Default Re: how does the user choose an integer size - (using JFrame Jpanel...)

    oh ok. Sorry I'm new here. I'll do that next time

    Thanks for your help. You really helped me

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: how does the user choose an integer size - (using JFrame Jpanel...)

    Just use a couple of JSpinners or JSliders, in the same frame along with the buttons.

    Too many popup dialogs can get annoying.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: how does the user choose an integer size - (using JFrame Jpanel...)

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. jFrame to jPanel using user input and if statements
    By mstratmann in forum AWT / Swing
    Replies: 2
    Last Post: 10-05-2012, 10:16 AM
  2. Replies: 5
    Last Post: 03-23-2011, 10:28 PM
  3. adding integer to the JPanel
    By navid in forum New To Java
    Replies: 2
    Last Post: 12-18-2010, 04:26 PM
  4. Read user input into integer array
    By varunb in forum New To Java
    Replies: 12
    Last Post: 07-09-2010, 12:50 PM
  5. Program where the user can choose the algorithm
    By le_albina@hotmail.com in forum New To Java
    Replies: 1
    Last Post: 03-18-2009, 04:45 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
  •