#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2007
    Posts
    1
    Rep Power
    0

    Drop Down Menu/ Radio Button Help


    So, I'm attempting to create a survey in Java and it's proving difficult to say the least.

    Currently I have 2 classes, Display and Main. Display has 3 methods which each display a question. Right now the method is using simple JOptionPane to prompt the user for an answer.

    String input1 = JOptionPane.showInputDialog ("Please select your favorite color \n red \n blue \n green");

    I really want to use a drop down list, or radio buttons for the selection of answers and I can't seem to do it.

    I tried using
    ________________________
    Object[] possibilities = {"ham", "spam", "yam"};
    String s = (String)JOptionPane.showInputDialog(
    frame,
    "Complete the sentence:\n"
    + "\"Green eggs and...\"",
    "Customized Dialog",
    JOptionPane.PLAIN_MESSAGE,
    icon,
    possibilities,
    "ham");
    ________________________
    for the drop down menu, but "frame," and "icon," were listed as errors because the variable could not be found.

    The code I found for sample radio buttons just went over my head.

    I pretty much only know very basic java, but if anyone has simple sample code that creates a survey using drop down menus or radio buttons it would be greatly appreciated. Normally I can figure out how to do things once I see a good example.
  2. #2
  3. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    Chicago, IL
    Posts
    10,131
    Rep Power
    5058
    for the drop down menu, but "frame," and "icon," were listed as errors because the variable could not be found.
    Where did you declare those variables (if they were declared)?

    ~
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}

IMN logo majestic logo threadwatch logo seochat tools logo