Microsoft KB Archive/201484

= BUG: Close Button Does Not Close Modeless AFC UIPropertyDialog =

Article ID: 201484

Article Last Modified on 11/14/2005

-

APPLIES TO


 * Microsoft Java Virtual Machine
 * Microsoft Software Development Kit for Java 3.2

-



This article was previously published under Q201484



SYMPTOMS
If a Java application or applet displays a modeless Application Foundation Classes (AFC) Property Sheet dialog box, the Close button on that dialog box has no effect. You must click OK or Cancel to close the dialog box.



RESOLUTION
You can avoid this behavior if you create the Property Sheet dialog box as a modal dialog box.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
When the Property Sheet dialog box is modeless and you click the Close button, it also does not result in a call to doApplyAction, doCancelAction, or doOKAction.

Steps to Reproduce Behavior
  Enter and compile the following program: // Propertydialog.java import java.awt.*; import com.ms.ui.*; import com.ms.ui.event.*; import java.awt.event.*; import com.ms.fx.*; import java.text.*;

class propertydialog extends UIFrame implements IUIActionListener {

public static void main(String args[]) {           try { propertydialog app = new propertydialog;

app.resize(200, 100); app.show; }           catch (Exception e) { e.printStackTrace; }         }

public boolean handleEvent(Event e)         { if (e.id == Event.WINDOW_DESTROY) System.exit(0);

return (super.handleEvent(e)); }

public propertydialog {           setLayout(new UIFlowLayout); UIPushButton pb = new UIPushButton("Create PropertyDialog",UIPushButton.RAISED); pb.addActionListener(this); add(pb); }

public void createDialog {           UIFrame frame = new UIFrame("Dialog"); UIPropertyDialog dialog = new myDialog(frame, false); myPage sheet = new myPage(dialog);

dialog.addPage("PropertySheet1",sheet); System.out.println("Displaying Property Sheet"); Object o = dialog.display; System.out.println("Property sheet returned " + o); }

public void actionPerformed(UIActionEvent event) {           createDialog; }

}

class myDialog extends UIPropertyDialog {        public myDialog(UIFrame f, boolean modal) { super(f, "UIPropertyDialog", modal, UIPropertyDialog.SMALL); }

public boolean doApplyAction(Event e, Object o) { System.out.println("Doing ApplyAction"); return true; }

public boolean doCancelAction(Event e, Object o) { System.out.println("Doing CancelAction"); return true; }

public boolean doOKAction(Event e, Object o) { System.out.println("Doing OKAction"); return true; }

}

class myPage extends UIPropertyPage {        myPage(UIPropertyDialog dialog) {           super(dialog); }

public boolean isApplyable { return true; }

public boolean addContent {

add(new UIText("This is UIPropertySheet"));

return true; }     }                         Run it using jview propertydialog and click Create PropertyDialog. Click the Close button on the Property Sheet dialog box.

RESULT: It does not close. Click OK or Cancel to close the dialog box.

