-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.2
-
generic, x86
-
generic, windows_nt
Name: dbT83986 Date: 07/21/99
Now I report this bug even if I found a related one (#4061116),
but there is not explained exactly what I get.
Now I start the SwingSet demo in netscape 4.06 or IE4
using the java plug-in contained in the jdk1.2.2.
All dialogs which are modal if I start the swingset as standalone,
are no more modal in the browser. That means I can for example
change the selected tab in the embedded applet.
That's not the desired behaviour for modal dialogs.
Thanks
Patrick
(Review ID: 88187)
======================================================================
Name: skT88420 Date: 07/21/99
I seem to be having trouble convincing you so let's try again !
The example code *does* demonstrate this problem.
Compile the applet and run it first using the appletviewer
(use avModal.html which is attached).
When you press the button on the applet a modal
dialog appears. You will notice that you cannot
press the button on the applet until the dialog box
is closed. This is the correct behaviour for a modal
dialog box.
If you close the dialog by pressing it's button you can then
press the button on the applet to create another dialog
Then run the applet in the 1.2.2 plugin using the attached
file testModal.html. Press the button and a dialog is
created. You will notice that you can still
press the button on the applet and create
more of these dialogs.
This is *not* the correct behaviour for a modal dialog !
Please fix this so that modal dialogs work correctly in the plugin
as well as in appletviewer.
Attached files:
======================
testModal.java
======================
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class testModal extends Applet implements ActionListener
{
Frame myFrame;
Button b1;
Button b2;
public testModal()
{
Button b1 = new Button();
b1.addActionListener(this);
b1.setLabel("Detonate");
b1.setActionCommand("detonate");
add(b1);
}
public void init()
{
// Get my Frame
Object widget = getParent();
while( ! (widget instanceof Frame) )
{
System.out.println( widget.getClass() );
widget = ( (Component) widget ).getParent();
}
myFrame = (Frame)widget;
// See if there is anything higher up
while ( widget != null )
{
System.out.println( widget.getClass() );
widget = ( (Component) widget ).getParent();
}
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("detonate"))
{
myDialog d1 = new myDialog(myFrame);
d1.pack();
d1.show();
}
else
{
System.out.println("Unknown command "+ae.getActionCommand());
}
}
public class myDialog extends Dialog implements ActionListener
{
public myDialog(Frame owner)
{
super(owner);
setModal(true);
setTitle("I am a Dialog");
Button b2 = new Button();
b2.setLabel("Go Away");
b2.addActionListener(this);
add(b2);
}
public void actionPerformed(ActionEvent ae)
{
dispose();
}
}
}
=======================
avModal.html
=======================
<html>
<body>
<applet CODE = testModal.class WIDTH = 200 HEIGHT = 200 ></applet>
</body>
</html>
========================
testModal.html
========================
<!--"CONVERTED_APPLET"-->
<!-- CONVERTER VERSION 1.0 -->
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 200 HEIGHT = 200 codebase="http://java.sun.com/products/plugin/1.2/jins
tall-12-win32.cab#Version=1,2,0,0">
<PARAM NAME = CODE VALUE = testModal.class >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.2" java_CODE = testModal.class
WIDTH = 200 HEIGHT = 200 pluginspage="http://java.sun.com/products/plugin/1.2/
plugin-install.html"><NOEMBED></COMMENT>
</NOEMBED></EMBED>
</OBJECT>
<!--
<APPLET CODE = testModal.class WIDTH = 200 HEIGHT = 200 >
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
===================
(Review ID: 88197)
======================================================================
Name: skT88420 Date: 09/22/99
=20
Build this program and run the applet if you push a buton, must be show a m=
odal dialog.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.net.*;
/**
* Esta clase lee las etiquetas PARAM en la p=E1gina HTML que las contiene
* y establece las propiedades de etiqueta del subprograma.
* La ejecuci=F3n del programa comienza con el m=E9todo init().
*/
public class M50iApplet extends JApplet
{=09
=09// Atributos
=09JButton=09=09=09buttonOk;
=09JTextField=09=09txUsuario;
=09ImageIcon=09=09icon;
=09frmStatico=09=09frm;
=09M50iApplet=09=09App;
=09// Constructor
=09public M50iApplet()
=09{
=09}
=09
=09/**
=09 * Punto de entrada del subprograma.
=09 */
=09public void init()
=09{
=09=09// initForm();
=09=09usePageParams();
=09=09=09=09
=09 App =3D this;
=09=09// Objeto que gestiona los eventos de los objetos del Applet
=09=09Listener=09actionlistener =3D new Listener();
=09=09// Hay que proteger contra las excepciones para que la p=E1gina no ca=
sque
=09=09// Hay que capturar una posible excepci=F3n.
=09=09// buttonOk
=09=09URL url =3D this.getClass().getResource("images\\document.gif");
=09=09icon =3D new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
=09=09buttonOk =3D new JButton("Crear dialogo", icon);
=09=09buttonOk.setSize(200, 100);
=09=09buttonOk.addActionListener(actionlistener);
=09=09=09
=09=09txUsuario =3D new JTextField("Esto es una prueba");
=09=09
=09=09// Configuraci=F3n del panel
=09=09//getContentPane().setLayout(new FlowLayout());
=09=09getContentPane().setLayout(null);
=09=09this.getContentPane().setBackground(java.awt.Color.white);
=09=09this.getContentPane().add(buttonOk, FlowLayout.LEFT);
=09=09// this.getContentPane().add(txUsuario, FlowLayout.RIGHT);
=09=09
=09=09// Situaci=F3n y aspecto en el panel
=09=09buttonOk.setBounds(0, 0, 200, 25);
=09}
=09private=09final String labelParam =3D "label";
=09private=09final String backgroundParam =3D "background";
=09private=09final String foregroundParam =3D "foreground";
=09/**
=09 * Lee los par=E1metros de la p=E1gina HTML que contiene el subprograma
=09 * y establece las propiedades del mismo.
=09 */
=09private void usePageParams()
=09{
=09=09final String defaultLabel =3D "Etiqueta predeterminada";
=09=09final String defaultBackground =3D "C0C0C0";
=09=09final String defaultForeground =3D "000000";
=09=09String labelValue;
=09=09String backgroundValue;
=09=09String foregroundValue;
=09=09/**
=09=09 * Leer las etiquetas <PARAM NAME=3D"label" VALUE=3D"cualquier cadena=
">,
=09=09 * <PARAM NAME=3D"background" VALUE=3D"rrggbb">,
=09=09 * y <PARAM NAME=3D"foreground" VALUE=3D"rrggbb">
=09=09 * en la p=E1gina HTML que contiene al subprograma.
=09=09 */
=09=09labelValue =3D getParameter(labelParam);
=09=09backgroundValue =3D getParameter(backgroundParam);
=09=09foregroundValue =3D getParameter(foregroundParam);
=09=09if ((labelValue =3D=3D null) || (backgroundValue =3D=3D null) ||
=09=09=09(foregroundValue =3D=3D null))
=09=09{
=09=09=09/**
=09=09=09 * Hay algo incorrecto en las etiquetas de host HTML.
=09=09=09 * Generar los valores predeterminados.
=09=09=09 */
=09=09=09labelValue =3D defaultLabel;
=09=09=09backgroundValue =3D defaultBackground;
=09=09=09foregroundValue =3D defaultForeground;
=09=09}
=09=09/**
=09=09 * Establecer la etiqueta de cadena, el color de fondo y los
=09=09 * colores de primer plano del subprograma.
=09=09 */
=09=09label1.setText(labelValue);
=09=09label1.setBackground(stringToColor(backgroundValue));
=09=09label1.setForeground(stringToColor(foregroundValue));
=09=09this.setBackground(stringToColor(backgroundValue));
=09=09this.setForeground(stringToColor(foregroundValue));
=09}
=09/**
=09 * Convierte una cadena con el formato "rrggbb" en un objeto awt.Color
=09 */
=09private Color stringToColor(String paramValue)
=09{
=09=09int red;
=09=09int green;
=09=09int blue;
=09=09red =3D (Integer.decode("0x" + paramValue.substring(0,2))).intValue()=
;
=09=09green =3D (Integer.decode("0x" + paramValue.substring(2,4))).intValue=
();
=09=09blue =3D (Integer.decode("0x" + paramValue.substring(4,6))).intValue(=
);
=09=09return new Color(red,green,blue);
=09}
=09/**
=09 * Interfaz externa utilizada por las herramientas de dise=F1o para most=
rar las propiedades de un subprograma.
=09 */
=09public String[][] getParameterInfo()
=09{
=09=09String[][] info =3D
=09=09{
=09=09=09{ labelParam, "String", "Cadena de etiqueta que se debe mostrar" }=
,
=09=09=09{ backgroundParam, "String", "Color de fondo, con formato \"rrggbb=
\"" },
=09=09=09{ foregroundParam, "String", "Color de primer plano, con formato \=
"rrggbb\"" },
=09=09};
=09=09return info;
=09}
=09Label label1 =3D new Label();
=09
=09// Tratamiento de los eventos del Applet
=09class Listener implements ActionListener {
=09public void actionPerformed(ActionEvent e){
=09 JComponent c =3D (JComponent) e.getSource();
=09=09
=09=09if (c=3D=3DbuttonOk){
=09=09=09Component comp =3D App.getContentPane();
=09=09=09while (comp !=3D null && !(comp instanceof Frame))
=09=09=09{
=09=09=09=09comp =3D comp.getParent();
=09=09=09}
=09=09=09
=09=09=09if (comp =3D=3D null) {
=09=09=09=09// This actually don't happens
=09=09=09=09System.out.println("No frame.");
=09=09=09=09System.exit(0);
=09=09=09}
=09=09=09=09=09=09=09=09
=09=09=09frm =3D new frmStatico((JFrame) ((Frame) comp), true);
=09=09}
=09}
=09} //Fin class Listener
}
NOTA: frmStatico extend from JDialog its constructor is:
=09public frmStatico(JFrame frm, boolean bModal)
=09{
=09=09super(frm, bModal);
=09=09// Requerido para la compatibilidad con el Dise=F1ador de formularios=
de Visual J++
=09=09initForm();
=09=09
=09=09this.setSize(300, 300);
=09=09this.setVisible(true);
=09=09App =3D this;
=09}
Error: don=B4t show the dialog.
I=B4ve seen a lot of coment of this bug, is true?
I use swing class JDK 1.2.2 and JFC 1.1.1
(Review ID: 95575)
======================================================================
- duplicates
-
JDK-4061116 Modal Dialog created by an applet does not have the correct behavior
-
- Resolved
-