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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started