Issue
I'm trying to put a JOptionPane before my JFrame form in Netbeans I have tried putting it in the source of the Frame, it shows me the optionpane but when i click ok the frame doesnt appear just the mini,max,close buttons of the window show. I don't know where exactly I'm supposed to put the code for the optionpane for it to show before the frame. Can anyone help me out?
public final class CineVivero extends javax.swing.JFrame {
public void popups(){
Object[] opening = {
"Bienvenido a Movie Counter"
+ "\n Esta aplicación fue hecha para Multicines Metro Vivero."
+ "\n Aquí se podra registrar el porcentaje de ocupación de"
+ "\n las instalaciones y los ingresos desde el momento que se"
+ "\n abre la aplicación.",
};
JOptionPane.showMessageDialog(null, opening, "Movie Counter", 2);
}
public CineVivero() {
popups();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CineVivero().setVisible(true);
}
});
}
Solution
but when i click ok the frame doesnt appear just the mini,max,close buttons of the window show
Have you added anything to frame? Have you specified it's size? By default, the window is 0x0
When I modify your code and set it's size (in this case 100x100
) it works fine for me
import javax.swing.JOptionPane;
public final class CineVivero extends javax.swing.JFrame {
public void popups() {
Object[] opening = {
"Bienvenido a Movie Counter"
+ "\n Esta aplicación fue hecha para Multicines Metro Vivero."
+ "\n Aquí se podra registrar el porcentaje de ocupación de"
+ "\n las instalaciones y los ingresos desde el momento que se"
+ "\n abre la aplicación.",};
JOptionPane.showMessageDialog(null, opening, "Movie Counter", 2);
}
public CineVivero() {
setSize(100, 100);
setLocationRelativeTo(null);
popups();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CineVivero().setVisible(true);
}
});
}
}
Answered By - MadProgrammer
Answer Checked By - Robin (JavaFixing Admin)