Using JOptionPane.showInputDialog to return an integer

I am currently using JOptionPane to return a string from the Object array i made with all possible choices.
     private static boolean determineService(){
          JLabel label;
          label=new JLabel("Please select which Service Model to use.",JLabel.CENTER);
          Object[] possibilities = {"AddressCleanse", "VIN", "PostalCode"};
          serviceModel = (String)JOptionPane.showInputDialog(
                              null,
                              label,
                              "Select Service",
                              JOptionPane.PLAIN_MESSAGE,null,
                              possibilities,
                              "AddressCleanse");
//          If a string was returned, say so.
          if ((serviceModel != null) && (serviceModel.length() > 0)) {
              System.out.println("You've selected " + serviceModel + "!");
              setVariables();
              return true;
          }else{
//               If you're here, the return value was null/empty.
               System.out.println("Null or Bad service selected!\n Exiting program.");
               return false;
          }I would like to instead return the response as an integr so I can then use a switch, rather than recursive if, else if logic.
Apparently java doesnt allow switches to use strings (like PHP does)
any ideas?

Just a question more than an answer: would using a hashmap ever work here? where the key is a string and the value is an (???) object that implements an interface that would allow you to call an appropriate method? Perhaps one could use the keySet() and toArray to build the Object array for the JOptionPane. I thought I read something about this somewhere, but am not sure....

Similar Messages

  • Help with JOptionPane.showInputDialog

    Hi!!
    People here helped me before so trying my luck again:)
    In order to get information from people I use JOptionPane.showInputdialog,
    problem is if I need to get 2 different types of info I have to use
            naam = JOptionPane.showInputDialog(null, "Geef speler naam:");
            land = JOptionPane.showInputDialog(null, "Geef Land Speler:");Is there anyway to make this happen in 1 screen?
    Or do I have to make a new frame for that with textfields and such?
    if so, anyone got an example?

    im new here:) so.. New to Java Technology suits me
    well I guess.No it doesn't. New to Java forum is for classpath questions, simple compile time problems and lazy students to cross post their assigments into.
    Swing questions, such as the one you asked, should be asked in the Swing forum because the people who answer questions in there are more knowledgeable about Swing. Plus you will almost 100% likely to find working example codes from previous posts in the Swing forum for Swing related questions.
    Much more likely than in here anyway.

  • Using JOptionPane in a non-event dispatching thread

    I am currently working on a screen that will need to called and displayed from a non-event dispatching thread. This dialog will also capture a user's selection and then use that information for later processing. Therefore, the dialog will need to halt the current thread until the user responds.
    To start, I tried using the JOptionPane.showInputDialog() method and set the options to a couple of objects. JOptionPane worked as advertised. It placed the objects into a combobox and allowed the user to select one of them. However, it also gave me something unexpected. It actually paused the non-event handling thread until the user had made a selection. This was done without the JOptionPane code being wrapped in a SwingUtilities.invokeLater() or some other device that would force it to be launched from an Event Handling Thread.
    Encouraged, I proceeded to use JOptionPane.showInputDialog() substituting the "message" Object with a fairly complex panel (JRadioButtons, JLists, JTextFields, etc.) that would display all of the variety of choices for the user. Now, when the screen pops up, it doesn't paint correctly (like what commonly occurs when try to perform a GUI update from a non-event dispatching thread) and the original thread continues without waiting for a user selection (which could be made if the screen painted correctly).
    So, here come the questions:
    1) Is what I am trying to do possible? Is it possible to create a fairly complex GUI panel and use it in one of the static JOptionPane.showXXXDialog() methods?
    2) If I can't use JOptionPane for this, should I be able to use JDialog to perform the same type function?
    3) If I can use JDialog or JFrame and get the threading done properly, how do I get the original thread to wait for the user to make a selection before proceeding?
    I have been working with Java and Swing for about 7-8 years and have done some fairly complex GUIs, but for some reason, I am stumped here. Any help would be appreciated.
    Thanks.

    This seems wierd that it is functioning this way. Generally, this is what is supposed to happen. If you call a JOptionPane.show... from the Event Dispatch Thread, the JOptionPane will actually begin processing events that normally the Event Dispatch Thread would handle. It does this until the user selects on options.
    If you call it from another thread, it uses the standard wait and notify.
    It could be that you are using showInputDialog for this, try showMessageDialog and see if that works. I believe showInputDialog is generally used for a single JTextField and JLabel.

  • Help using JOptionPane

    please tell me how can i do following:
    I want to add strings using JOptionPane.showInputDialog( ) method. in an ArrayList() of strings only.
    I want to show input dialog box to user continously till user presses "enter" from keyboard.
    please tell me the way to stop the loop when user presses "Enter" from keyboard.
    //what i have done:
    //created new ArrayList()
    myStrings = new ArrayList();
    while(1)
        String theString = JOptionPane.showInputDialog("Enter string ");
        myStrings.add(theString);
    }

    I want to show input dialog box to user continously
    till user presses "enter" from keyboard.
    please tell me the way to stop the loop when user
    presses "Enter" from keyboard.You probably want to end the loop when the user clicks the cancel button on the dialog. Clicking the enter button invokes the button that has focus.

  • JOptionPane.showInputDialog Help!!!!

    Hello,
    I'm using JOptionPane.showInputDialog(Component parentComponent,
    Object message,
    String title,
    int messageType,
    Icon icon,
    Object[] selectionValues,
    Object initialSelectionValue ).
    which prompts the user to add some text and the same will be stored for later retrieval.
    In this case, JOptionPane pops up with a label, textfield,OK & Cancel buttons.
    Default focus is given to to the TextField.
    Is there anyway to get access to the TextField via code ?
    For example, if the user types "Hello World" in the given TextField, then I need to get the Text entered in
    the TextField in the following manner.
    String myStr = myJOptionPaneTextField().getText();
    System.out.println("Entered Text is "+ myStr);
    How can I Achieve the same ?
    Thanks in advance
    Regards
    vargav

    Why? At what point do you know you should manipulate the text? Usually, it would be when the user clicks OK, at which point it doesn't matter because the dialog is dismissed. So what kind of operations do you expect to be able to do?
    Aside from that, I'm not sure how to get the text field in the option pane, per se... It can be gotten by digging thru the pane's components til you find a text field. But you'd need to do that in a separate thread. So it's not really feasible to do that.... There is an alternative:
    The message is an object, and it can be an array of objects, which will all be added, and thus can include a message string and a text field...
    JTextField myfield = new JTextField();
    Object[] obj = new Object[2];
    obj[0] = "Enter some text here:";
    obj[1] = myfield;
    if(JOptionPane.showOptionDialog(obj, "Enter Text", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
       String value = myfield.getText();
    }Then you can do whatever you want with the text field... but the same problem is there, you have lost the dialog before you can do anything.

  • How to put  JPasswordField on JOptionPane.showInputDialog ?

    Hi,
    I want to use "JOptionPane.showInputDialog" and a "JPasswordField" on it.
    How can I put "JPasswordField" on JOptionPane.showInputDialog?
    Here is my code but there is a simple JTextField automatically generated on showInputDialog.
    // JPasswordField pf = new JPasswordField();
    // String str = new String (pf.getPassword());
    String pass = JOptionPane.showInputDialog(null,
                                   "Enter password to access:",
                                   "Demanding Password",
                                   JOptionPane.QUESTION_MESSAGE);I thank you in advance.

    Don't crosspost. This is a Swing related questions and you've already posted the question on the Swing forum.

  • JOptionPane.showInputDialog with echo chars

    Is there any way to have use JOptionPane.showInputDialog() to have echo characters?
    so that when you type something in the dialog, you can only see ***** just like JPasswordField

    The [url http://java.sun.com/developer/JDCTechTips/]Beyond the Basics of JOptionPane article might give you some ideas..

  • Reading Integer using JOptionPane

    I'm trying to write a Java program using JOptionPane dialog/display boxes that reads an integer and checks whether it is even using true/false statements. I also want the program must check if the number the user entered is between 1 and 1000.
    I haven't found alot of help in the book I have, so I'm hoping somone has some example modules.
    Thank you....
    Scott

    Hi,
    Hope this helps you a bit. Just Uncomment the for your even number testing.
    import javax.swing.JOptionPane;
    public class OptionPaneTest {
         public static boolean isNumber(String args)
              if(args.length() > 3)
                   throw new IllegalArgumentException("Invalid argument");
              else
              boolean isNumber = false;
              for(int i = 0; i < args.length(); i++)
                   char c = args.charAt(i);
                   if(Character.isDigit(c))
                        isNumber = true;
                   else
                      isNumber = false;
              return isNumber;
         public static boolean isEven(int aNumber)
              int a = aNumber & 1;
              return (a == 0);          
          * @param args
         public static void main(String[] args) {          
              String s = JOptionPane.showInputDialog("Please enter number between 0 to 999");
              System.out.println("Is Number " + isNumber(s));
              if(isNumber(s))
              int number = Integer.valueOf(s);
              System.out.println("Number " + number + "is Even " + isEven(number));          
    //          for(int i = 0; i < 999; i++)
    //          System.out.println(i + " is " + isEven(i));
    }

  • Comple errors using JOptionPane

    I'm trying to write a Java program using JOptionPane dialog/display boxes that reads an integer and checks whether it is even using true/false statements. I also want the program must check if the number the user entered is between 1 and 1000.
    I haven't found alot of help in the book I have and i've found some help in another forum but it doesn't seem to compile well, I get the following errors:
    IntegerRead.java:39: cannot find symbol
    symbol : method valueOf(java.lang.String)
    location: class Integer
    int number = Integer.valueOf(s);
    ^
    Integer.java:13: cannot find symbol
    symbol : class Scanner
    location: class Integer
    Scanner input = new Scanner( System.in );
    ^
    Integer.java:13: cannot find symbol
    symbol : class Scanner
    location: class Integer
    Scanner input = new Scanner( System.in );
    Here is the code:
    // Assignment 2.1: IntegerRead.java
    // This program reads an integer, checks if it's even and is between 1 and 1000.
    import javax.swing.JOptionPane; // program uses class JOptionPane
    public class IntegerRead
    public static boolean isNumber(String args)
    if(args.length() > 3)
    throw new IllegalArgumentException("Invalid argument");
    else
    boolean isNumber = false;
    for(int i = 0; i < args.length(); i++)
    char c = args.charAt(i);
    if(Character.isDigit(c))
    isNumber = true;
    else
    isNumber = false;
    return isNumber;
    public static boolean isEven(int aNumber)
    int a = aNumber & 1;
    return (a == 0);
    public static void main(String args[])
    String s = JOptionPane.showInputDialog("Please enter number between 0 to 999");
    System.out.println("Is Number " + isNumber(s));
    if(isNumber(s))
    int number = Integer.valueOf(s);
    System.out.println("Number " + number + "is Even " + isEven(number));
    for(int i = 0; i < 999; i++)
    System.out.println(i + " is " + isEven(i));
    I know i'm missing very simple. I'm new and have tried to build upon what I have so far, but I can't figure it out.
    Thanks....
    Edited by: Scott.Dishman on Jul 9, 2008 4:07 PM

    You have a class named Integer somewhere on your class path. Get rid of it or rename it. If you've already renamed your Integer.java file, you still need to delete the Integer.class file. You should never create your own class that has the same name as a class in the standard java.lang package.

  • How to use Math.random() to generate an integer within a range

    How can I generate a random integer from 1 to 10 using the Math.random() method?
    Thanks.

    Then why do i get this compile-time error?
    found   : double
    required: int
                        matrix[i][j] = (int) 11 * Math.random();
    matrix is an array of integers:
    String colNumStr = JOptionPane.showInputDialog("Please specify the number of rows");
        String rowNumStr = JOptionPane.showInputDialog("Please specify the number of columns");
        int rowNumInt = Integer.parseInt(rowNumStr);
        int colNumInt = Integer.parseInt(colNumStr);
        int [][] matrix = new int [rowNumInt][colNumInt];

  • JOptionPane.showInputDialog and the cancel button

    so i'm using a JOptionPane.showInputDialog, and everything works except when i click the cancel button to exit the window, it gives me an error.
    how can i remedy this?
    here's a section of my code: (a is an array, as is b)
    firstWord = JOptionPane.showInputDialog
    ("What company's sloagan is/was: "+a[count]+"?");
    if(firstWord.equalsIgnoreCase(b[count]))
    JOptionPane.showMessageDialog (null,
    "Thats Right, the company was "+b[count]+".");
    count++;
    int YesNo = JOptionPane.showConfirmDialog (null,
    "Do you want to play again?", "Choose One", JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);
    if(YesNo==1) //this should exit out if you click no
    System.exit (0);
    if(count==10)
    JOptionPane.showMessageDialog(null,
    "Game Over. You Won.");
    System.exit (0);
    else
    JOptionPane.showMessageDialog (null,
    "Sorry, you aren't that smart. Guess again.");
    }]

    1- Seems like you misstyped your code tags...
    2- When you say: "it gives me an error", please provide details (e.g. stack trace)
    3- Read the API doc, it says: showInputDialog returns user's input, or null meaning the user canceled the input.
    So firstWord.equalsIgnoreCase(b[count]) will throw a NullPointerException in that case.
    You might check for null value.
    Note:str1.equals(str2) will throw a NullPointerException when str1 is null, but str2 can be null without a NullPointerException being thrown:String str1 = null;
    String str2 = "toto";
    System.out.println(str1.equals(str2)); // NullPointerException
    System.out.println(str2.equals(str1)); // ok (prints false)

  • JOptionPane.showInputDialog without CANCEL Button

    How can I do a JOptionPane.showInputDialog without CANCEL Button.
    Besides if I press OK without tyoing anything, will a null String but returned?
    Thanks

    I don't think you can with an Input Dialog. Normally, you want to give the user a chance to cancel the operation. Here is an example using a Message Dialog. After the user hits OK, you can get the text from the text field.          JPanel p = new JPanel(new GridLayout(2,1));
              JTextField t = new JTextField();
              JLabel l = new JLabel("A message");
              p.add(l);
              p.add(t);
              JOptionPane.showMessageDialog(null,p,"Title",JOptionPane.PLAIN_MESSAGE);

  • JOptionPane.showInputDialog with a JList?

    Is there any quick and easy way to use the JOptionPane.showInputDialog with a JList? the default is a drop down menu. Thanks!

    Is there any quick and easy way to use the
    JOptionPane.showInputDialog with a JList? the default
    is a drop down menu. Thanks!I have found a way to this. You need to write your own JOptionPane
    class MyJOptionPane
        public static Object showListInputDialog(Component parentComponent, Object message, String title, Object[] selecttionValues)
            Object defaultOptionPaneUI = UIManager.get("OptionPaneUI");
            UIManager.put("OptionPaneUI", "MyBasicOptionPaneUI");
            Object object = JOptionPane.showInputDialog(parentComponent, message, title, JOptionPane.PLAIN_MESSAGE, null,
                    selecttionValues, selecttionValues[0]);
            UIManager.put("OptionPaneUI", defaultOptionPaneUI);
            return object;
    }And then create your own MyBasicOptionPaneUI extending from javax.swing.plaf.basic.BasicOptionPaneUI with 2 methods overridden. The codes are copied from javax.swing.plaf.basic.BasicOptionPaneUI and modified to get rid of JComboBox.
    public class MyBasicOptionPaneUI extends BasicOptionPaneUI
        public MyBasicOptionPaneUI()
            super();
        public static ComponentUI createUI(JComponent x) {
             return new MyBasicOptionPaneUI();
        protected Object getMessage()
            inputComponent = null;
            if (optionPane != null) {
                if (optionPane.getWantsInput()) {
                    /* Create a user component to capture the input. If the
                       selectionValues are non null  with any size ,
                       it'll be a list, otherwise it'll be a textfield. */
                    Object message = optionPane.getMessage();
                    Object[] sValues = optionPane.getSelectionValues();
                    Object inputValue = optionPane
                            .getInitialSelectionValue();
                    JComponent toAdd;
                    if (sValues != null) {
                            JList list = new JList(sValues);
                            JScrollPane sp = new JScrollPane(list);
                            list.setVisibleRowCount(10);
                            list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                            if (inputValue != null)
                                list.setSelectedValue(inputValue, true);
                            list.addMouseListener(new ListSelectionListener());
                            toAdd = sp;
                            inputComponent = list;
                    } else {
                        MultiplexingTextField tf = new MultiplexingTextField(20);
                        tf.setKeyStrokes(new KeyStroke[]{
                            KeyStroke.getKeyStroke("ENTER")});
                        if (inputValue != null) {
                            String inputString = inputValue.toString();
                            tf.setText(inputString);
                            tf.setSelectionStart(0);
                            tf.setSelectionEnd(inputString.length());
                        tf.addActionListener(new TextFieldActionListener());
                        toAdd = inputComponent = tf;
                    Object[] newMessage;
                    if (message == null) {
                        newMessage = new Object[1];
                        newMessage[0] = toAdd;
                    } else {
                        newMessage = new Object[2];
                        newMessage[0] = message;
                        newMessage[1] = toAdd;
                    return newMessage;
                return optionPane.getMessage();
            return null;
        private static class MultiplexingTextField extends JTextField
            private KeyStroke[] strokes;
            MultiplexingTextField(int cols)
                super(cols);
             * Sets the KeyStrokes that will be additional processed for
             * ancestor bindings.
            void setKeyStrokes(KeyStroke[] strokes)
                this.strokes = strokes;
            protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,
                                                int condition, boolean pressed)
                boolean processed = super.processKeyBinding(ks, e, condition,
                        pressed);
                if (processed && condition != JComponent.WHEN_IN_FOCUSED_WINDOW) {
                    for (int counter = strokes.length - 1; counter >= 0;
                         counter--) {
                        if (strokes[counter].equals(ks)) {
                            // Returning false will allow further processing
                            // of the bindings, eg our parent Containers will get a
                            // crack at them.
                            return false;
                return processed;
        private class ListSelectionListener extends MouseAdapter
            public void mousePressed(MouseEvent e)
                if (e.getClickCount() == 2) {
                    JList list = (JList) e.getSource();
                    int index = list.locationToIndex(e.getPoint());
                    optionPane.setInputValue(list.getModel().getElementAt(index));
        private class TextFieldActionListener implements ActionListener
            public void actionPerformed(ActionEvent e)
                optionPane.setInputValue(((JTextField) e.getSource()).getText());
    }

  • JOptionPane.showInputDialog and Focus

    I have a program that allows the user to type in a String in a text box and when they hit the enter key the text will appear in a text area. I've also added a menu bar to the program. When the user clicks on File and then Connect from the menu bar I want a JOptionPane to pop up that asks for the user to type in a username and then prompt for a password. And I've gotten all of that to work. Now for the problem. I click on file from the menu bar and then connect and it prompts me for the username as it should. I am able to just type in a phrase in the text field of the username dialog box and hit the enter key and then it prompts me for my password. I am still able to type in a phrase in the text field of the password Dialog box, however when I hit the enter key, the Dialog box does not close as it did for the username Dialog box. It will still close if I click on the OK button, but just pressing the enter key does not close the Dialog box as it did when it prompted for a username. I'm thinking I need to direct the focus to the password dialog box, but not sure how to go about doing this. Any help in solving this problem would be greatly appreciated.
    Here is my code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class TestJOptionPane extends JFrame implements ActionListener{
         private static int borderwidth = 570;
         private static int borderheight = 500;
         private JPanel p1 = new JPanel();
         private JMenu m1 = new JMenu("File");
         private JMenuBar mb1 = new JMenuBar();
         private JTextArea ta1 = new JTextArea("");
         private JTextField tf1 =new JTextField();
         private Container pane;
         private static String s1, username, password;
         private JMenuItem [] mia1 = {new JMenuItem("Connect"),new JMenuItem("DisConnect"),
              new JMenuItem("New..."), new JMenuItem ("Open..."), new JMenuItem ("Save"),
              new JMenuItem ("Save As..."), new JMenuItem ("Exit")};
    public TestJOptionPane (){
         pane = this.getContentPane();
              addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
         dispose();
    System.exit(0);
         setJMenuBar(mb1);
    mb1.add(m1);
    for(int j=0; j<mia1.length; j++){
         m1.add(mia1[j]);
    p1.setLayout( new BorderLayout(0,0));
    setSize(borderwidth, borderheight);
    pane.add(p1);
              p1.add(tf1, BorderLayout.NORTH);
              p1.add(ta1, BorderLayout.CENTER);
              this.show();
              tf1.addActionListener(this);
              for(int j=0; j<mia1.length; j++){
                   mia1[j].addActionListener(this);
         public void actionPerformed(ActionEvent e){
              Object source = e.getSource();
              if(source.equals(mia1 [0])){
                   username = JOptionPane.showInputDialog(pane, "Username");
                   password = JOptionPane.showInputDialog(pane, "Password");
              if(source.equals(tf1)){
                   s1=tf1.getText();
                   ta1.append(s1+"\n");
                   s1="";
                   tf1.setText("");
         public static void main(String args[]){
              TestJOptionPane test= new TestJOptionPane();
    }

    But using JOptionPane doesn't get the focus when you call itworks ok like this
    import javax.swing.*;
    import java.awt.event.*;
    class Testing
      public Testing()
        final JPasswordField pwd = new JPasswordField(10);
        ActionListener al = new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            pwd.requestFocusInWindow();}};
        javax.swing.Timer timer = new javax.swing.Timer(250,al);
        timer.setRepeats(false);
        timer.start();
        int action = JOptionPane.showConfirmDialog(null, pwd,"Enter Password",JOptionPane.OK_CANCEL_OPTION);
        if(action < 0)JOptionPane.showMessageDialog(null,"Cancel, X or escape key selected");
        else JOptionPane.showMessageDialog(null,"Your password is "+new String(pwd.getPassword()));
        System.exit(0);
      public static void main(String args[]){new Testing();}
    }

  • Using JOptionPane to exit program & Using toString method

    Hello,
    In my program I have to use a toString method below
    public String toString(Hw1NCBEmployee[] e)
            String returnMe = String.format(getStoreName() + "\n" + getStoreAddress() + "\n" + getCityState() +  "\nYou have " + getEmpCount() + "employee(s)");
            return returnMe;
    }Now, at first, when I initially tested my code, it was working just fine, printing out the right way
    Point is -- now that Im practically finished with my program, and am going back and running it - calling the toString method gives me the address rather than the information . . . Can anyone help me with this issue??
    Also, Im using JOptionPane to display everything, but -- at first, it worked fine, then (around the same time I started having the above problem) it stopped exiting the do-while loop:
    while(go)
                 int option = JOptionPane.showConfirmDialog(null, "Do you want to enter employee information?", "Welcome!", JOptionPane.YES_NO_OPTION);
                     if(option == JOptionPane.NO_OPTION)
                        go = false;  //exit loop
            

    ncjb wrote:
    well, for the toString - I have to print out the info inside the array -- am I right in thinking that the only way to do this is to pass in the array ??If the array is part of the class then there is no need to pass it as a parameter. If it is being passed in from outside the class then I have to question your design. Why should class X being formatting data that is not a representation of itself?
    and i have 2 other files that go with this program . . . I just want to know if there is a way to make sure that when the user presses the NO option, it will exit the loop -- the piece of code you see if apart of an entire method (not long) -- do you want me to include this??You read that link I provided REAL quick!

Maybe you are looking for

  • Error while retrieving a password for credential

    Hi All, I am getting following error while deploying ADS application. Please help me to resolve it. NWDS 04s. Adobe Version 7.02 error:   com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.base.core.PDFDocumentRuntimeException: ADS Render Exception

  • I get an error message when trying to connect my iphone to a lenovo thinkpad

    I cannot get my Iphone to work on the Lenovo Thinkpad edge 520, when I connect the phone it brings up an error saying there was a problem loading the device. In the control panel I get a yellow exclamatin mark next to the mobile usb device. I tried t

  • How to show in a report a pdf blob from database

    Hi all We are working on report 6i and report 10. We have a report wich needs to show a blob field from database that storages a pdf (type application/pdf). OLE2 is deprecated. The pdf blob field must be displayed in a preview and must be printed. In

  • Cannot connect to EDGE

    Have had iPhone for one week and have never connected to EDGE - only ask for WiFi connection. Can someone tell me if there is something I need to do to have device connect to WEDGE - very frustrating as I cannot get email, etc, unless I am at home or

  • [HELP]don't allow access folder in web root, but allow dowload files in it?

    Hi all! I got a big problem, at least ... with me .. uhm ... I have a web application, which I allow user upload file on, I save that file in a folder below the web root, I mean ... www.mywebapp/files/uploadFile.zip <--- something like that... I don'