Results 1 to 1 of 1
- 04-24-2011, 04:00 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
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
-
JOptionPane
By thorobred in forum EclipseReplies: 4Last Post: 04-19-2011, 04:15 AM -
JOptionPane with a comboBox with data read from a text file
By rdmapes in forum AWT / SwingReplies: 0Last Post: 11-21-2010, 05:10 PM -
JOptionpane Data to a new file
By javaisntcoffee123 in forum Advanced JavaReplies: 1Last Post: 04-15-2010, 05:21 PM -
JOptionPane
By izzy in forum New To JavaReplies: 1Last Post: 03-17-2010, 04:55 PM -
JOptionpane
By tommyyyy in forum New To JavaReplies: 2Last Post: 03-20-2009, 08:33 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks