Results 1 to 7 of 7
- 04-23-2011, 07:26 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
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
- 04-23-2011, 07:29 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
What have you tried so far? We are here to help, however; you have to make an effort.
- 04-23-2011, 07:37 AM #3
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
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
}
}
}
- 04-23-2011, 08:22 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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).
- 04-23-2011, 08:29 AM #5
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
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?
- 04-23-2011, 08:34 AM #6
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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.
- 04-23-2011, 08:38 AM #7
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
Similar Threads
-
JFrame - Output and Input in Frame - menu choice and simple Calculator
By sambo731 in forum AWT / SwingReplies: 3Last Post: 08-07-2010, 05:28 AM -
Menu Options For User
By mnand in forum New To JavaReplies: 1Last Post: 02-02-2009, 03:12 AM -
[SOLVED] How do I make user inputs appear bolded??
By mjm1189 in forum EclipseReplies: 0Last Post: 09-13-2008, 12:59 AM -
want to make a menu bar for image processing
By vidhi in forum Java 2DReplies: 1Last Post: 01-15-2008, 07:12 PM -
How to make the menu bar objects appears from right to left
By JavaBean in forum AWT / SwingReplies: 3Last Post: 07-19-2007, 11:12 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks