Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Popup Frame

 
Shalini Chandel
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to create an application that will popup after every 2 or 3 hours and will remain on screen untill unless all the fields filled by user.

Sort of modal dialog box that will capture the screen..sort of shutdown dialog box...

any idea..how can we do that..

regards,
Shalini
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nikolaos Kalligiannis
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!