Question: langauage: java using JFChooser and menu system. why does n't JFChooser open up when it's inside a repeating menu system(do while loop). for example in

langauage: java

using JFChooser and menu system. why does n't JFChooser open up when it's inside a repeating menu system(do while loop). for example in a menu, if you pick one, the show open dialog should open up for you to choose a file to load data into console. use format below.

for example: you have one class called Dialog. one class called menu. and one main class to test the results. import javax.swing.JFileChooser. import scanner class.

public class Dialog{ public Dialog() { } public static void readFile() { JFileChooser file = new JFileChooser("."); int fileState = file.showOpenDialog(null); } }

public class Menu() { boolean go = true; public Menu() { } public void dataMenu() { int choice =0; do { System.out.println(1. open diaglog/n 2. Statement /n 3. Exit); choice = input.nextLine(); if( choice == 1) { Dialog.readFile(): go = false: } else if( choice == 2) { System.out.println("Great job"); go = false: } else if(choice == 3) { System.out.println("you have exited. the program"); System.exit(0); go = false; } }while(go); } }

public class Main{ Menu n1 = new Menu(); n1.dataMenu(); }

note: so when you pick option 1, the dialog for you to pick a file to read into console should open up. the menu shouldn't break .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!