Got a problem that i hope some could help me with. I'm using a JOptionPane in my program, but when i run the class, the first JOptionPane will pop up in the background, so you don't see it in eclipse untill you alt + tab and find it.
How do i get it so it runs up front?
My code of the GUI class, that will create my pane.
import java.io.IOException;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
public class GUI {
@SuppressWarnings("unused")
public void getConfirmation() throws IOException {
JFrame frame = new JFrame();
Object[] options = {"Continue","Stop procedure"};
int n = JOptionPane.showOptionDialog(frame,
"Would you like to continue or stop procedure?",
"Plese confirm",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);
frame.toFront();
frame.repaint();
if(JOptionPane.YES_OPTION == 1) {
// Program will keep going
}
else if (JOptionPane.NO_OPTION == 0) {
System.out.println(" ");
System.out.println("Procedure terminated");
System.out.println(" ");
}
}
}
I run the GUI class from another class like this: here you see some of the code from my client class.
System.out.println("You received " + fromServer + " from the server");
System.out.println("Please answer confirmationbox" + "\n\n");
GUI.getConfirmation();
But i found out, its only the first time you run it that it will start in background, after that i runs like normal when i try to run it again.