My tutor is having issues directing me with the problem below. Hoping I can find some answers from the community.
I am trying to add an image pop out to a simple console application, and from research it would appear I need to use JImage/JFrame (I think). However, my tutor believes I can use the below code (which doesn't work when I use it, and tutor has no idea why not).
System.out.println(new Picture(FileChooser.pickAFile()).show()). This returns "Picture can not be resolved to a type".
I believe it is supposed to allow me to select a picture, but it doesn't. Also it doesn't matter whether I put the destination of the picture directly in to the code either.
Simply put, I need a picture to print out to screen/new window when an option is selected from my menu, if anyone can help with this, it would be great!
Full code below (section is down near the bottom / loadMuseums method)
package CWK2;
//IMPORTS REQUIRED FOR COMPILATION
import java.util.Scanner;
public class menuSystem {
public static void main(String[] args) throws Exception {
boolean incorrect = false; // SETS THE VARIABLE FOR THE WHILE CONDITION BELOW
String input = "";
while (incorrect == false) { // WHILE STATEMENT TO MAKE THE BELOW A
// REPEATING MENU IF WRONG INPUT
incorrect = true; // TO INITIALLY MAKE THE LOOP ONLY RUN ONCE (E.G CORRECT INPUT)
// PRINTING OF THE MENU
System.out.println("**WELCOME TO THE TOUR GUIDE**");
System.out.println();
System.out.println("1. Museums");
System.out.println("2. Eating Out");
System.out.println("3. Shopping Centres");
System.out.println("4. Historical / Places of Interest");
System.out.println();
System.out.print("Please enter your choice (1/2/3/4) : ");
Scanner choice = new Scanner(System.in);
input = choice.next();
System.out.println();
switch (input) { // SWITCHES FROM USER'S INPUT
case "1": {
loadMuseum();
choice.close(); // CLOSES THE SCANNER AND STOPS MENU REPEAT
break;
}
case "2": {
loadEateries();
choice.close(); // CLOSES THE SCANNER AND STOPS MENU REPEAT
break;
}
case "3": {
loadShops();
choice.close(); // CLOSES THE SCANNER AND STOPS MENU REPEAT
break;
}
case "4": {
loadHistoricals();
choice.close(); // CLOSES THE SCANNER AND STOPS MENU REPEAT
break;
}
default: { // DEFAULT METHOD USED FOR INCORRECT INPUT (ANYTHING
// OTHER THAN 1-4)
System.out.println("");
System.out.println("You have entered an incorrect option.");
System.out.println("You will need to try that again. Remember 1-4 are your choices.");
System.out.println("");
incorrect = false; // KEEPS THE REPEATING MENU GOING
break;
}
}
}
}
public static void loadMuseum() {
//insert pic
System.out.println(new Picture(FileChooser.pickAFile()).show()).
System.out.println("");
System.out.println("");
//insert pic
System.out.println("");
System.out.println("");
}
private static void loadEateries() {
//insert pic
System.out.println(""); //insert bio
System.out.println("");
//insert pic
System.out.println("");
System.out.println("");
}
private static void loadShops() {
//insert pic
System.out.println(""); //insert bio
System.out.println("");
//insert pic
System.out.println("");
System.out.println("");
}
private static void loadHistoricals() {
//insert pic
System.out.println(""); //insert bio
System.out.println("");
//insert pic
System.out.println(""); //insert bio
System.out.println("");
}
}