1

I am a beginner, and I am developing an Online Test in Java.

I have timer in the code. Assume the test time to be 60 seconds. After expiry of the time I have to show the result frame (Actually I have 10 frames for 10 questions and a result frame).

How do I set the visiblity of the opened frame at the instant of expiry to false?

Alex Gittemeier
  • 5,224
  • 30
  • 55
  • 8
    Start with with [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice) then take a look at [How to use Swing Timers](http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html) and you might find [How to use CardLayout](http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html) of some help – MadProgrammer Jul 05 '13 at 07:28

1 Answers1

1

Because multiple frames are problematic, use a dialog. In this JOptionTimeTest, a JOptionPane is embedded in a JDialog to allow submitting manually before the timer expires. Note the dispatch of a WindowEvent.WINDOW_CLOSING event to close the dialog.

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045