单击后如何使对话框窗口按钮执行某些操作?

时间:2018-04-25 21:41:21

标签: java

这是我可以使对话框窗口变得简单的代码,但是如何编程显示对话框按钮的按钮?可能吗?这是带按钮的图像:
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){
    }
}    

}

0 个答案:

没有答案