Results 1 to 1 of 1
  1. #1
    tinaman is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default Help with getting file and doing something with it from JOptionpane

    Hello.
    I am trying to get the below code to take the filename that is entered from the end user and then get it to do the task that that user selects if it is 1,2,3,4

    When I get the menu to appear it lets me insert the filename but doesnt prompt me for the coices 1-4.

    I am missing alot ... can you help me please?

    Java Code:
    import jm.util.*;
    import javax.swing.*;
    import java.io.*;
    import java.io.IOException;
    public class music
    {
    	public static void main(String [] args)throws IOException
    	{
    	String namefile1="", namefile2="";	
    	String message1= "Please input the name of the file you wish to manipulate";
    	String message2= "input file where to write";
    	String PatternFile = "[a-z0-9]{1,32}.mp3",menuChoicePattern = "[0-9]{1}";
    	String advice1="This file type does not exist, please insert again in mp3 format";
    	String advice2="Filename supplied does not exist, please retry";
    	String menuOptions  = "1 Normalise\n" + 
    	                      "2 Looping\n" +
    	                      "3 Insert Silence\n" + 
    	                      "4 Envelope\n" + 
    	                      "0 Exit\n\n" +
    	                      "Enter your selection:";
    	File readFile;
    	boolean choice1 = false, choice2 = false, choice3 = false;	
    	while(!choice1)
    		{
    			namefile1=JOptionPane.showInputDialog(null,message1);
    			if(namefile1!=null)
    				{
    				if (!(namefile1.matches(PatternFile)))
    				JOptionPane.showMessageDialog(null,advice1);
    				else
    					{
    					readFile = new File(namefile1);
    					if(!(readFile.exists()))
    					JOptionPane.showMessageDialog(null,advice2);
    					else
    						{
    						choice1= true;
    						}
    					}
    				}
    		}
    		while(!choice2)
    			{
    				namefile2=JOptionPane.showInputDialog(null,message2);
    				if(namefile2!=null)
    				{
    					if (!(namefile2.matches(PatternFile)))
    					JOptionPane.showMessageDialog(null,advice1);
    					else
    						{
    						choice2 = true;
    						}
    				}
    			}
    		
    		{
    			
    		}
    		
    		
    		
    		
    	}
    	
    }
    Last edited by tinaman; 04-25-2011 at 11:24 AM. Reason: moderator edit: code tags added

Similar Threads

  1. JOptionPane
    By thorobred in forum Eclipse
    Replies: 4
    Last Post: 04-19-2011, 04:15 AM
  2. Replies: 0
    Last Post: 11-21-2010, 05:10 PM
  3. JOptionpane Data to a new file
    By javaisntcoffee123 in forum Advanced Java
    Replies: 1
    Last Post: 04-15-2010, 05:21 PM
  4. JOptionPane
    By izzy in forum New To Java
    Replies: 1
    Last Post: 03-17-2010, 04:55 PM
  5. JOptionpane
    By tommyyyy in forum New To Java
    Replies: 2
    Last Post: 03-20-2009, 08:33 AM

Tags for this Thread

Posting Permissions

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