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

    Default asking user to make choice through menu

    Hi.

    I want to create a menu using JOPtionpane and ask the user to input a filename eg - music.mp3.

    I want to check if the file exists and if not let the user know and get them to retry.

    If it does exist I want to ask them through a menu to choose 1 of 3 options to manipulae that file. I want this choice to be made by accepting a choosen number.

    If they choose one I want to reverse that music file.
    If they choose two I want to loop the music file
    if they choose three I want them to mix the music file.

    I then want to output that file to them.

    Any help .... please ... please .... please

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    What have you tried so far? We are here to help, however; you have to make an effort.

  3. #3
    tinaman is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    Here is what I have done over the last 4 hours.
    I have been doing it with 6 weeks and have dumped loads of them. I feel as though I have started messing it up more than ever now.

    import javax.swing.JOptionPane;
    import java.io.File;
    import java.io.IOException;
    import jm.music.data.*;
    import jm.music.tools.*;
    import jm.util.*;
    import java.io.*;

    public class Project2
    {
    public static void main(String [] args) throws IOException
    {
    //create menu and display it
    String inputFile;
    String outputFile
    inputFile = JOptionPane.showInputDialog(null,"Enter the music file name");
    //get filename from user

    //check filename
    File aFile = new File(inputFile)
    File outputaFile = new File(outputFilename)
    if (aFile.exists())
    {
    float [] data = Read.audio(aFile)
    //reverse the order of samples
    float [] reversed = new float[data.length]
    for (int i = 0; i < data.length; i++)
    reversed[data.length - i - 1] = data [i];
    Write.audio(reversed, "ReversedAudio.mp3");


    //case1- valid no entered?
    //case2- invalid no entered
    //case3- 0 or null(x) or cancel

    //get filename from user

    //check filename exists

    //get output filename

    //create float array

    //call functions that do operation
    }
    }
    }

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Do you need to use an option pane for the file prompt? You may want to check out that. As far as actually playing the music, I am not much help(others may be though).

  5. #5
    tinaman is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    yes need to use an option pane for it.
    I can figure out the playing of the music if you could help me in any way with the rest.

    Can you tell me how to set up the menu so that if th file does exist that it prompts the user to enter a choice of 3 options? If they choose no 1 - how do I ask the program to go and run that request?

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Assuming you are using a JOptionPane for the menu it's very similar to the one which you used to extract the file. Have the message contain the choices they can choose, then parse the string response and use a switch case to call the correct method.

    If you want to get more advanced you can have a correctly chosen file open a custom jdialog which uses buttons and action listening to perform the correct option. For bother options I consider you check out the tutorials for a more thorough explanation.

  7. #7
    tinaman is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

Similar Threads

  1. Replies: 3
    Last Post: 08-07-2010, 06:28 AM
  2. Menu Options For User
    By mnand in forum New To Java
    Replies: 1
    Last Post: 02-02-2009, 04:12 AM
  3. Replies: 0
    Last Post: 09-13-2008, 01:59 AM
  4. Replies: 1
    Last Post: 01-15-2008, 08:12 PM
  5. Replies: 3
    Last Post: 07-19-2007, 12:12 PM

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
  •