0

This is the code I can make the dialog window easy but how do I program the button that shows up with the dialog button? Is it possible? This is the image with the button:
This is the image with the button

    package Millionaire;

    import java.awt.Component;
    import javax.swing.JOptionPane;

    public class Time extends javax.swing.JFrame implements Runnable {
         public static int timer;

         public void run(){

         try{

            while(true){
                if(DoYouWantToBeAMillionaire.timerActive){
                    if (timer == 0){                    
                        QuestionScreen.btnClicked = true;
                        QuestionScreen.answerCorrect = false;
                        LoseScreen LoseWindow = new LoseScreen();
                        LoseWindow.setVisible(true);
                        QuestionScreen.CloseScreen=true;
                        Component frame = null;
                        JOptionPane.showMessageDialog(frame, "SORRY,TIME'S UP","ERROR", JOptionPane.ERROR_MESSAGE);
                        break;
                    }
                    else {
                        System.out.println(timer);
                        Thread.sleep(1000);
                        timer -= 1;
                    }
                }
                else{
                    break;
                }

            }

        }       
        catch(Exception e){
    }
}    

}

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
Jason Gao
  • 21
  • 2
  • Please follow Java naming conventions :packages, attributes, variables, parameters, method have to start in lowerCase – azro Apr 25 '18 at 21:43
  • do you know how to code the button that pops up along the dialog window though? is there a way? – Jason Gao Apr 25 '18 at 21:48
  • If I comment here, be sure that I read your post, no need to ask again in comment – azro Apr 25 '18 at 21:49
  • Possible duplicate [Disable ok button on JOptionPane.dialog until user gives an input](https://stackoverflow.com/questions/14334931/disable-ok-button-on-joptionpane-dialog-until-user-gives-an-input/14335083#14335083) – MadProgrammer Apr 25 '18 at 22:09
  • not what i was looking for, but thanks for the reply – Jason Gao Apr 25 '18 at 22:12

0 Answers0