473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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(Frame frame) {
super(frame);
System.out.println("TestDialog - constructor");

addWindowListener(this);

TextField text = new TextField(10);

Button button = new Button("ok");
{
button.setActionCommand("ok");
button.addActionListener(this);
}
add(text, "Center");
add(button, "South");

pack();

setModal(true);
}

public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("TestDialog - actionPerformed()");
fireActionEvent(new ActionEvent(this, e.getID(),
e.getActionCommand()));
}

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

public void addActionListener(ActionListener actionlistener) {
listeners = AWTEventMulticaster.add(listeners, actionlistener);
}

public void setVisible(boolean flag) {
System.out.println("TestDialog - setVisible() -> flag=" + flag);
if (flag) {
Dimension screensize =
Toolkit.getDefaultToolkit().getScreenSize();
Dimension dimension = getSize();
setLocation( (screensize.width - dimension.width) / 2,
(screensize.height - dimension.height) / 2 );
}
super.setVisible(flag);
}

public void windowClosing(WindowEvent e) {
actionPerformed(new ActionEvent(this, e.getID(), "closing"));
}

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

public void windowClosed(WindowEvent e) {
actionPerformed(new ActionEvent(this, e.getID(), "closed"));
}

public void windowDeactivated(WindowEvent e) {
actionPerformed(new ActionEvent(this, e.getID(),
"deactivated"));
}

public void windowDeiconified(WindowEvent e) {
actionPerformed(new ActionEvent(this, e.getID(),
"deiconified"));
}

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

public void windowOpened(WindowEvent e) {
actionPerformed(new ActionEvent(this, e.getID(), "opened"));
}

}

------------------------------------------------------------------------
--------------------------- FirstApplet.java ---------------------------
/*
* FirstApplet.java
*
* 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.println("FirstApplet - init()");
}

public void start() {
System.out.println("FirstApplet - start()");
}

public void paint(Graphics g) {
System.out.println("FirstApplet - paint()");
g.drawString(_msg, 25, 50);
}

public void printEmpty() {
System.out.println("FirstApplet - print()");
_msg = "print";
}

public void printString(String msg) {
System.out.println("FirstApplet - printString()");
_msg = msg;
}
}
------------------------------------------------------------------------
Jul 17 '05 #1
2 3468
Michael wrote:
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?


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

Jul 17 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael wrote:
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.


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/pDSZwxczzJRavJYRAhjuAKCCqXkW/TAuYVcLxZl4/4/fq0d9SgCg7NS9
HtSK6b3hHddX/qrjvVrQ/6E=
=YC/E
-----END PGP SIGNATURE-----
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: WMMorgan | last post by:
There's a website I like to visit that has an user-interactive java application. There's a "visual applet" component and "control applet" component. (No, it's not an adult or porno site.) But...
3
by: Jeff T. | last post by:
I have an applet that sizes itself to the size of the browser frame that it is running in. On IE the applet resizes upon dragging the frame divider. I'm having a problem with getting this...
2
by: Jonathan | last post by:
Hi I'm doing a project for school and wrote an applet that makes a socket connection to a server (smae host as webserver) that was setup for this project. In the applet there are 3 buttons and by...
4
by: Warrick Wilson | last post by:
I've got a web page that uses frames. One of the frames loads an HTML page that redirects to a 3rd HTML page. This third page loads a Java applet - ProScroll.class - that runs a "news ticker"...
2
by: martin de vroom | last post by:
Hi, I have a web page that opens a modal dialog (client side) in the following manner onclick="window.showModalDialog('/dialog.asp',null,'dialogHeight: 200px; dialogWidth: 400px; dialogTop:...
4
by: dave | last post by:
I have an app that uses the OpenFile Dialog class. When I invoke the ShowDialog method, the hourglass appears and just stays. The dialog window never opens. I created a test form with an...
2
by: MarkMurphy | last post by:
Is there a limitation in ASP.NET in this regard? From the aspx code below, I can successfully call a Java applet. If I try the identical thing in a user control ascx however, the control loads...
3
by: Earl Teigrob | last post by:
Can a Modal Dialog Box do forms ASP.NET forms validation from within the Modal Box? I want to pop up a dialog box to the user and have it do its own post backs with validation checking and then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.