I read the answer :
--------------------------
For the timing aspect, either use a javax.swing.Timer or a thread that sleeps for a certain amount of time.
As for modal dialogs - you want it so that the user cannot access any other windows at all (even other applications or the desktop)? This is not possible in pure Java AFAIK.
---------------------------------
given to your question and I believe the second part is not entirely accurate. You may not be able to forbit access to other windows application or windows in general but you can take over the screen with a JFrame. I had the same problem with restricting access to windows in a control system we are currently developing. Since we have no keyboards attached to the system (use an onscreen one) this solution works fine with us.
USE in the class with your main method
public ClassWithMainMethod () {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = env.getDefaultScreenDevice();
GraphicsConfiguration gc = device.getDefaultConfiguration();
jFrame frame = new FrameMain(gc);
private void showItUndecorated(){
this.frame.setSize(1024, 768);
this.frame.setUndecorated(true);
device.setFullScreenWindow(frame);
}
USE a constructor for your full screen swing frame as
public jFrame(GraphicsConfiguration gc) {
super(gc); //argument is your Graphics configuration.
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
//your initialization here
} catch (Exception exception) {
exception.printStackTrace();
}
}
The result is a frame without its main top bar and no exit, minimize etc buttons. The drawback is that users can use the keyboard windows keys or Alt-Tab to bring up windows. This is something we didn't have to sort out (remember no keyboards).
You should also keep in mind that you can set the graphics configuration once you create the frame instance. If you keep it hidden and then you want it to appear you:
1.have to hide the currently displayed jFrame before showing you undecorated frame
2. Keep a reference to the frame you hidden (eg.pass it as parameter in the undecorated frame constructor) so that you can unhide it.
3. Create boolean means off checking that the undecorated frame has not had its graphics already set eg
in jFrame create
property
private boolean isGraphicsSet = false;
getter/setter
public void setMyGraphics(boolean x) {
this.isGraphicsSet = x; //check if windowless state is already achieved and window has been allready drawn(trick)
}
public boolean getMyGraphics() {
return this.isGraphicsSet;
}
Hope this helps