Dialog within applet hangs itself

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael

    Dialog within applet hangs itself

    Hello

    Currently I'm migrating an applet from Java 1.1 to 1.3.

    Targetplattform :
    Microsoft Internet Explorer 5.x with Sun's Java VM 1.3.1

    Problem:
    The attached applet works fine with the Microsoft VM. But when I use
    Suns' VM the applet hangs after opening the dialog. And you have to
    shutdown the browser with the help of the Taskmanager.

    Wenn ich das angef|gte Applet starte, funktioniert es in der M

    Reason:
    I was able to lead back the problem to the setVisible(true ) method of
    the java.awt.Dialog class. This method does not return.

    Question:
    Does anything changed within the AWT from Java 1.1 to 1.3?

    Thank you very much
    Michael


    --------------------------- TestDialog.java ---------------------------
    /*
    * TestDialog.java
    *
    * Created on 28. Oktober 2003, 09:04
    */

    package ch.softlab.sebc ;

    import java.awt.*;
    import java.awt.event. *;

    /**
    *
    * @author herrem
    */
    public class TestDialog extends Dialog implements ActionListener,
    WindowListener{

    /** Creates a new instance of TestDialog */
    private ActionListener listeners = null;

    public TestDialog(Fram e frame) {
    super(frame);
    System.out.prin tln("TestDialog - constructor");

    addWindowListen er(this);

    TextField text = new TextField(10);

    Button button = new Button("ok");
    {
    button.setActio nCommand("ok");
    button.addActio nListener(this) ;
    }
    add(text, "Center");
    add(button, "South");

    pack();

    setModal(true);
    }

    public void actionPerformed (java.awt.event .ActionEvent e) {
    System.out.prin tln("TestDialog - actionPerformed ()");
    fireActionEvent (new ActionEvent(thi s, e.getID(),
    e.getActionComm and()));
    }

    public void fireActionEvent (ActionEvent e) {
    if (listeners != null) {
    listeners.actio nPerformed(e);
    }
    }

    public void addActionListen er(ActionListen er actionlistener) {
    listeners = AWTEventMultica ster.add(listen ers, actionlistener) ;
    }

    public void setVisible(bool ean flag) {
    System.out.prin tln("TestDialog - setVisible() -> flag=" + flag);
    if (flag) {
    Dimension screensize =
    Toolkit.getDefa ultToolkit().ge tScreenSize();
    Dimension dimension = getSize();
    setLocation( (screensize.wid th - dimension.width ) / 2,
    (screensize.hei ght - dimension.heigh t) / 2 );
    }
    super.setVisibl e(flag);
    }

    public void windowClosing(W indowEvent e) {
    actionPerformed (new ActionEvent(thi s, e.getID(), "closing")) ;
    }

    public void windowActivated (WindowEvent e) {
    actionPerformed (new ActionEvent(thi s, e.getID(), "activated" ));
    }

    public void windowClosed(Wi ndowEvent e) {
    actionPerformed (new ActionEvent(thi s, e.getID(), "closed"));
    }

    public void windowDeactivat ed(WindowEvent e) {
    actionPerformed (new ActionEvent(thi s, e.getID(),
    "deactivated")) ;
    }

    public void windowDeiconifi ed(WindowEvent e) {
    actionPerformed (new ActionEvent(thi s, e.getID(),
    "deiconified")) ;
    }

    public void windowIconified (WindowEvent e) {
    actionPerformed (new ActionEvent(thi s, e.getID(), "iconified" ));
    }

    public void windowOpened(Wi ndowEvent e) {
    actionPerformed (new ActionEvent(thi s, e.getID(), "opened"));
    }

    }

    ------------------------------------------------------------------------
    --------------------------- FirstApplet.jav a ---------------------------
    /*
    * FirstApplet.jav a
    *
    * Created on 9. Oktober 2003, 15:51
    */

    package ch.softlab.sebc ;

    import java.applet.*;
    import java.awt.*;

    /**
    *
    * @author herrem
    */
    public class FirstApplet extends Applet {

    /** Initialization method that will be called after the applet is
    loaded
    * into the browser.
    */
    private String _msg = "Hello World";

    public void init() {
    System.out.prin tln("FirstApple t - init()");
    }

    public void start() {
    System.out.prin tln("FirstApple t - start()");
    }

    public void paint(Graphics g) {
    System.out.prin tln("FirstApple t - paint()");
    g.drawString(_m sg, 25, 50);
    }

    public void printEmpty() {
    System.out.prin tln("FirstApple t - print()");
    _msg = "print";
    }

    public void printString(Str ing msg) {
    System.out.prin tln("FirstApple t - printString()") ;
    _msg = msg;
    }


    }
    ------------------------------------------------------------------------
  • Raymond DeCampo

    #2
    Re: Dialog within applet hangs itself

    Michael wrote:[color=blue]
    > Hello
    >
    > Currently I'm migrating an applet from Java 1.1 to 1.3.
    >
    > Targetplattform :
    > Microsoft Internet Explorer 5.x with Sun's Java VM 1.3.1
    >
    > Problem:
    > The attached applet works fine with the Microsoft VM. But when I use
    > Suns' VM the applet hangs after opening the dialog. And you have to
    > shutdown the browser with the help of the Taskmanager.
    >
    > Wenn ich das angef|gte Applet starte, funktioniert es in der M
    >
    > Reason:
    > I was able to lead back the problem to the setVisible(true ) method of
    > the java.awt.Dialog class. This method does not return.
    >
    > Question:
    > Does anything changed within the AWT from Java 1.1 to 1.3?
    >[/color]

    Michael,

    My first instinct is that the dialog is somehow sized too small or
    placed off the screen or is in some other way impossible to detect.
    Since it is a modal dialog this might create the issue you are seeing.
    Based on your code, it looks like you are OK in setting the size (via
    pack()) and in setting the location (assuming the screen size is
    reported properly). I recommend printing out what the dialog says its
    size and location are before showing it (also, you may want to make it
    non-modal, at least for debugging purposes).

    Ray

    Comment

    • Chris

      #3
      Re: Dialog within applet hangs itself

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Michael wrote:
      [color=blue]
      > Reason:
      > I was able to lead back the problem to the setVisible(true ) method
      > of the java.awt.Dialog class. This method does not return.[/color]

      Hello,
      I'm not absolutely sure about setVisible(true ), but I know that show()
      on a modal dialogue doesn't return until the dialogue is disposed.
      setVisible(true ) may operate the same way. Maybe you need to display
      the dialogue in a new thread, or maybe you need to reorganize your
      code to take this into account.

      - --
      Chris
      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.2.2 (GNU/Linux)

      iD8DBQE/pDSZwxczzJRavJY RAhjuAKCCqXkW/TAuYVcLxZl4/4/fq0d9SgCg7NS9
      HtSK6b3hHddX/qrjvVrQ/6E=
      =YC/E
      -----END PGP SIGNATURE-----

      Comment

      Working...