Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Opening a Dialog/Frame from Applet

 
Rakesh Ray
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am openning Dialog/Frame from the Applet for some user inputs..
Now when user clicks on the applet this frame/dialog loses focus and goes back.
How do I keep it in front??
I tried Dialog.setModal(), it is not helping ...
For Frame, there is no setModal...
I would apprecaite if someone can suggest me the way to keep either frame/dialog in the front so that it does not go back when user clicks the applet...
Regards.
 
sabbir kazi
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may use the "showInputDialog" method of JOptionPane class.
---------------------------------------------------
showInputDialog
public static String showInputDialog(Component parentComponent, Object message)
Shows a question-message dialog requesting input from the user parented to parentComponent. The dialog is displayed in the Component's frame, and is usually positioned below the Component.

Parameters:
parentComponent - the parent Component for the dialog
message - the Object to display
 
Rakesh Ray
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kazi for the reply.
I was looking solutin for jdk1.0...
Anyway I could find something as follows...
public Frame GetAppletFrame()
{
//Find out the Frame for the applet, which would be browser frame.
// Jdk1.0 do not have any method to find Applet's Frame.
// This function was need to overcome several java bugs.
// 1. We need to pass Frame of the applet to the Dialog so that it can remain modal
// 2. Applet's Cursor change does not work and we need to use Frame's Cursor functions.
Frame appletFrame=null;
Component parent = getParent(); //Get Applet's parent, presumable the browser Frame.
while ( (parent != null) && !(parent instanceof Frame))
{
parent = parent.getParent();
}

if (parent instanceof Frame)
appletFrame = (Frame)parent;
else //Incase you do not find the frame..
appletFrame = new Frame();
return appletFrame;
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic