Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JApplet: how to show new JFrame allways at top

Status
Not open for further replies.

fuadhamidov

Programmer
Sep 22, 2003
98
TR
hi everybody

i have developed an applet (JApplet) project.
In this project i open new window (JFrame) on applet to get some input and i want to disable parent window (JApplet)

Although i have been able to lock parent, i can not stay child window(JFrame) always at the top of the parent window (JApplet)

it works fine while my "parent JPanel"s parent is JFrame

the code

Code:
public void showChildPanel() {
   new ChildPanel(getMyContainer(this.getParent())).show();
}

private Container getMyContainer( Container c ) {
   while ( c != null ) {
      if ( c instanceof JApplet ) {
          //c = ( ( JApplet ) c ).getContentPane();
          c = c.getParent();
          c = c.getParent();
          break;
       } else if ( c instanceof JFrame ) {
          break;
       }
       c = c.getParent();
   }
   return ( Container ) c;
}

Code:
public class ChildPanel extends JFrame {
   public ChildPanel( Container _caller ) {
      this.caller = _caller;
      this.caller.setEnabled( false );
   }
}





 
As far as I know, this can't be done. The JFrame is the top-most Swing construct and has no control over anything outside it (so it can't enforce itself as 'topmost').

If I'm wrong (and I could be), I'd be interested in the solution.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
thanks timw,

using JFrame isn't "must" for me. i can use any component.

i want that child box or frame, must always be on front of (or top of) the parent window.

if the child is opened while the user select browser that contains applet, the child window must be in front of the parent.

like JOptionPane,
 
I'll admit that I've done very little Applet coding.

It would seem on the face of it that a JDialog would give you the behaviour you want. The problem is that this expects a Dialog or Frame reference of the thing it is to be 'modal' with respect to. With an Applet, you're UI class heirarchy is separate to the Window one. Have a look in the JDK API docs at the javax.swing.JRootPane class for a diagram of this.

Like I said before, this may be impossible due to an Applet being an embedded thing with no control / reference to its container.

Maybe someone with more experience will have something to say?

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top