How can I bring a pop up window forward in front of the program in JAVA?

How can I bring a pop up window forward in front of the program in JAVA?
0

#1

As you can see below in my code when clicks on the helpsection method a PDF file opens. I was wondering instead of the PDF being behind the program, how can I bring that window in front of the program? I tried using Desktop.setVisible(true); However, I had no luck I got the error messages.

enter image description here

enter image description here

PROGRAM CODE

import java.util.Scanner; //taking input from user
import java.io.File;
import java.awt.Desktop;

public static void helpsection() {
        try {
            Desktop.getDesktop().open(new File("CVliamdocherty.pdf"));
            Desktop.setVisible(true);
        } catch(Exception e) {
            System.out.println(e);
        }
        System.out.println("Would you like to go back into the program to select a course to find out your grade?");
        System.out.println("You can enter 'Yes' or 'No' only.");
        outcome2 = userinput.next();
        if (outcome2.equalsIgnoreCase("Yes")) {
            step1();
        } else if (outcome2.equalsIgnoreCase("No")) {
            System.out.println((username)+" thanks for using Liam's UCAS grade calculator.");
            System.exit(0);
        } else { 
            System.out.println("You have entered an invalid value.");
            System.out.println("The program now will re run, make sure to enter the correct value next time.");
            step1();
        } 
    }

#2

setVisible(true);
toFront();


#3

“Cannot find symbol” error


#4

Try this after:
public static void helpsection( ) { …
if( !isVisible( ) )
setVisible( true );
setExtendedState( JFrame.NORMAL );
toFront( );
setAlwaysOnTop( true );